[Python-checkins] r51258 - python/trunk/Modules/_ctypes/_ctypes.c python/trunk/Modules/_ctypes/callproc.c
neal.norwitz
python-checkins at python.org
Sun Aug 13 20:40:41 CEST 2006
Author: neal.norwitz
Date: Sun Aug 13 20:40:39 2006
New Revision: 51258
Modified:
python/trunk/Modules/_ctypes/_ctypes.c
python/trunk/Modules/_ctypes/callproc.c
Log:
Handle alloca failures.
Klocwork 225-228
Modified: python/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/trunk/Modules/_ctypes/_ctypes.c (original)
+++ python/trunk/Modules/_ctypes/_ctypes.c Sun Aug 13 20:40:39 2006
@@ -2475,6 +2475,8 @@
where n is 0, 4, 8, 12, ..., 128
*/
mangled_name = alloca(strlen(name) + 1 + 1 + 1 + 3); /* \0 _ @ %d */
+ if (!mangled_name)
+ return NULL;
for (i = 0; i < 32; ++i) {
sprintf(mangled_name, "_%s@%d", name, i*4);
address = (PPROC)GetProcAddress(handle, mangled_name);
Modified: python/trunk/Modules/_ctypes/callproc.c
==============================================================================
--- python/trunk/Modules/_ctypes/callproc.c (original)
+++ python/trunk/Modules/_ctypes/callproc.c Sun Aug 13 20:40:39 2006
@@ -915,6 +915,10 @@
#endif
args = (struct argument *)alloca(sizeof(struct argument) * argcount);
+ if (!args) {
+ PyErr_NoMemory();
+ return NULL;
+ }
memset(args, 0, sizeof(struct argument) * argcount);
argtype_count = argtypes ? PyTuple_GET_SIZE(argtypes) : 0;
#ifdef MS_WIN32
@@ -968,6 +972,10 @@
avalues = (void **)alloca(sizeof(void *) * argcount);
atypes = (ffi_type **)alloca(sizeof(ffi_type *) * argcount);
+ if (!resbuf || !avalues || !atypes) {
+ PyErr_NoMemory();
+ goto cleanup;
+ }
for (i = 0; i < argcount; ++i) {
atypes[i] = args[i].ffi_type;
if (atypes[i]->type == FFI_TYPE_STRUCT)
@@ -1068,6 +1076,11 @@
return NULL;
#ifdef _UNICODE
name = alloca((PyString_Size(nameobj) + 1) * sizeof(WCHAR));
+ if (!name) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
{
int r;
char *aname = PyString_AsString(nameobj);
More information about the Python-checkins
mailing list