diff --git a/PC/getpathp.c b/PC/getpathp.c index 25b328b260c..c7ddf1ea6b3 100644 --- a/PC/getpathp.c +++ b/PC/getpathp.c @@ -321,7 +321,6 @@ getpythonregpath(HKEY keyBase, int skipcore) dataBuf = PyMem_RawMalloc((dataSize+1) * sizeof(WCHAR)); if (dataBuf) { WCHAR *szCur = dataBuf; - DWORD reqdSize = dataSize; /* Copy our collected strings */ for (index=0;index 0) { @@ -349,6 +348,10 @@ getpythonregpath(HKEY keyBase, int skipcore) */ rc = RegQueryValueExW(newKey, NULL, 0, NULL, (LPBYTE)szCur, &dataSize); + if (rc != ERROR_SUCCESS) { + PyMem_RawFree(dataBuf); + goto done; + } } /* And set the result - caller must free */ retval = dataBuf;