diff --git a/PC/_winreg.c b/PC/_winreg.c index d60b1511929..472e84e24d4 100644 --- a/PC/_winreg.c +++ b/PC/_winreg.c @@ -948,8 +948,10 @@ Reg2Py(char *retDataBuf, DWORD retDataSize, DWORD typ) fixupMultiSZ(str, retDataBuf, retDataSize); obData = PyList_New(s); - if (obData == NULL) + if (obData == NULL) { + free(str); return NULL; + } for (index = 0; index < s; index++) { size_t len = _mbstrlen(str[index]); @@ -957,6 +959,7 @@ Reg2Py(char *retDataBuf, DWORD retDataSize, DWORD typ) PyErr_SetString(PyExc_OverflowError, "registry string is too long for a Python string"); Py_DECREF(obData); + free(str); return NULL; } PyList_SetItem(obData,