]> granicus.if.org Git - python/commitdiff
Move assert to after NULL check, otherwise we deref NULL in the assert.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 19 Aug 2006 04:18:39 +0000 (04:18 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 19 Aug 2006 04:18:39 +0000 (04:18 +0000)
Klocwork #307

Modules/_ctypes/stgdict.c

index 149a7ea5e82f2ebc48288eeec8fde51fb2f8b168..182b9af03630b9015d9dea77bcc38726282fb3c4 100644 (file)
@@ -208,12 +208,12 @@ MakeFields(PyObject *type, CFieldObject *descr,
                        continue;
                }
                new_descr = (CFieldObject *)PyObject_CallObject((PyObject *)&CField_Type, NULL);
-               assert(new_descr->ob_type == &CField_Type);
                if (new_descr == NULL) {
                        Py_DECREF(fdescr);
                        Py_DECREF(fieldlist);
                        return -1;
                }
+               assert(new_descr->ob_type == &CField_Type);
                new_descr->size = fdescr->size;
                new_descr->offset = fdescr->offset + offset;
                new_descr->index = fdescr->index + index;