Skip to content

Commit

Permalink
MERGE: Closes python#20908: Memory leak in Reg2Py()
Browse files Browse the repository at this point in the history
  • Loading branch information
jcea committed Mar 13, 2014
2 parents d73721a + 782c4cf commit 58c767f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,15 +943,18 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)

fixupMultiSZ(str, data, len);
obData = PyList_New(s);
if (obData == NULL)
if (obData == NULL) {
free(str);
return NULL;
}
for (index = 0; index < s; index++)
{
size_t len = wcslen(str[index]);
if (len > INT_MAX) {
PyErr_SetString(PyExc_OverflowError,
"registry string is too long for a Python string");
Py_DECREF(obData);
free(str);
return NULL;
}
PyList_SetItem(obData,
Expand Down

0 comments on commit 58c767f

Please sign in to comment.