Kaydet (Commit) 3a6a0431 authored tarafından Thomas Heller's avatar Thomas Heller

Fix refcount leak in error cases. Bug found by coverity.

üst 847c43a2
......@@ -1452,11 +1452,14 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
size += 1; /* terminating NUL */
size *= sizeof(wchar_t);
buffer = (wchar_t *)PyMem_Malloc(size);
if (!buffer)
if (!buffer) {
Py_DECREF(value);
return PyErr_NoMemory();
}
memset(buffer, 0, size);
keep = PyCObject_FromVoidPtr(buffer, PyMem_Free);
if (!keep) {
Py_DECREF(value);
PyMem_Free(buffer);
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment