Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 782c4cf

Browse files
committed
Closes #20908: Memory leak in Reg2Py()
1 parent 45fc871 commit 782c4cf

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

PC/winreg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,15 +943,18 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
943943

944944
fixupMultiSZ(str, data, len);
945945
obData = PyList_New(s);
946-
if (obData == NULL)
946+
if (obData == NULL) {
947+
free(str);
947948
return NULL;
949+
}
948950
for (index = 0; index < s; index++)
949951
{
950952
size_t len = wcslen(str[index]);
951953
if (len > INT_MAX) {
952954
PyErr_SetString(PyExc_OverflowError,
953955
"registry string is too long for a Python string");
954956
Py_DECREF(obData);
957+
free(str);
955958
return NULL;
956959
}
957960
PyList_SetItem(obData,

0 commit comments

Comments
 (0)