Fix Fatal Python error: UNREF invalid object in debug builds

PyObject_Del() should only be called on the self object in
a dealloc call, not after failing to make a new object.
Replace with Py_DECREF, which eventually calls PyObject_Del()

http://bugs.python.org/issue3299#msg78740
https://mail.python.org/pipermail/python-dev/2003-February/033258.html
This commit is contained in:
wiredfool 2016-05-30 03:16:16 -07:00
parent 2af16a7b58
commit 72c45e6f5d
2 changed files with 3 additions and 3 deletions

View File

@ -153,7 +153,7 @@ getfont(PyObject* self_, PyObject* args, PyObject* kw)
if (self->font_bytes) {
PyMem_Free(self->font_bytes);
}
PyObject_Del(self);
Py_DECREF(self);
return geterror(error);
}

4
map.c
View File

@ -73,7 +73,7 @@ PyImaging_MapperNew(const char* filename, int readonly)
NULL);
if (mapper->hFile == (HANDLE)-1) {
PyErr_SetString(PyExc_IOError, "cannot open file");
PyObject_Del(mapper);
Py_DECREF(mapper);
return NULL;
}
@ -84,7 +84,7 @@ PyImaging_MapperNew(const char* filename, int readonly)
if (mapper->hMap == (HANDLE)-1) {
CloseHandle(mapper->hFile);
PyErr_SetString(PyExc_IOError, "cannot map file");
PyObject_Del(mapper);
Py_DECREF(mapper);
return NULL;
}