From: Neal Norwitz Date: Mon, 14 Aug 2006 00:59:03 +0000 (+0000) Subject: Can't return NULL from a void function. If there is a memory error, X-Git-Tag: v2.5c1~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=af33f2d57191985a9bf13b40549b6294873de68b;p=thirdparty%2FPython%2Fcpython.git Can't return NULL from a void function. If there is a memory error, about the best we can do is call PyErr_WriteUnraisable and go on. We won't be able to do the call below either, so verify delstr is valid. --- diff --git a/Objects/classobject.c b/Objects/classobject.c index 0e4356b4c8a7..b79f06e9cbea 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -624,9 +624,9 @@ instance_dealloc(register PyInstanceObject *inst) if (delstr == NULL) { delstr = PyString_InternFromString("__del__"); if (delstr == NULL) - return NULL; + PyErr_WriteUnraisable((PyObject*)inst); } - if ((del = instance_getattr2(inst, delstr)) != NULL) { + if (delstr && (del = instance_getattr2(inst, delstr)) != NULL) { PyObject *res = PyEval_CallObject(del, (PyObject *)NULL); if (res == NULL) PyErr_WriteUnraisable(del);