From: Neal Norwitz Date: Sat, 19 Aug 2006 04:23:04 +0000 (+0000) Subject: Move assert to after NULL check, otherwise we deref NULL in the assert. X-Git-Tag: v2.6a1~2770 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b17eba8be14d258a9d4e747b35c3f7ef22f81ca;p=python Move assert to after NULL check, otherwise we deref NULL in the assert. Klocwork #307 --- diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c index 149a7ea5e8..182b9af036 100644 --- a/Modules/_ctypes/stgdict.c +++ b/Modules/_ctypes/stgdict.c @@ -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;