summaryrefslogtreecommitdiffstats
path: root/PC/getpathp.c
diff options
context:
space:
mode:
authorMark Hammond <mhammond@skippinet.com.au>2000-09-10 09:14:53 (GMT)
committerMark Hammond <mhammond@skippinet.com.au>2000-09-10 09:14:53 (GMT)
commite61aca7d4a17f231d0058c6be736bc1eea40c081 (patch)
tree51b8ad7c5f58f7f76a28fa7ee0a6f735f66d55e7 /PC/getpathp.c
parentbb307343e4d2f2781249e560090260d121607626 (diff)
downloadcpython-e61aca7d4a17f231d0058c6be736bc1eea40c081.zip
cpython-e61aca7d4a17f231d0058c6be736bc1eea40c081.tar.gz
cpython-e61aca7d4a17f231d0058c6be736bc1eea40c081.tar.bz2
Patch for [ Bug #113828 ] getpythonregpath with null data in registry key
If there was a NULL registry key, Python could barf. Also wraps some surrounding lines to 80 chars.
Diffstat (limited to 'PC/getpathp.c')
-rw-r--r--PC/getpathp.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/PC/getpathp.c b/PC/getpathp.c
index 3ed9124..a3c2bf0 100644
--- a/PC/getpathp.c
+++ b/PC/getpathp.c
@@ -263,7 +263,9 @@ getpythonregpath(HKEY keyBase, int skipcore)
if (reqdSize) {
ppPaths[index] = malloc(reqdSize);
if (ppPaths[index]) {
- RegQueryValueEx(subKey, NULL, 0, NULL, (LPBYTE)ppPaths[index], &reqdSize);
+ RegQueryValueEx(subKey, NULL, 0, NULL,
+ (LPBYTE)ppPaths[index],
+ &reqdSize);
dataSize += reqdSize + 1; /* 1 for the ";" */
}
}
@@ -275,23 +277,27 @@ getpythonregpath(HKEY keyBase, int skipcore)
DWORD reqdSize = dataSize;
/* Copy our collected strings */
for (index=0;index<numKeys;index++) {
- int len;
if (index > 0) {
*(szCur++) = _T(';');
dataSize--;
}
- len = _tcslen(ppPaths[index]);
- _tcsncpy(szCur, ppPaths[index], len);
- szCur += len;
- dataSize -= len;
+ if (ppPaths[index]) {
+ int len = _tcslen(ppPaths[index]);
+ _tcsncpy(szCur, ppPaths[index], len);
+ szCur += len;
+ dataSize -= len;
+ }
}
if (skipcore)
*szCur = '\0';
else {
*(szCur++) = _T(';');
dataSize--;
- /* Now append the core path entries - this will include the NULL */
- rc = RegQueryValueEx(newKey, NULL, 0, NULL, (LPBYTE)szCur, &dataSize);
+ /* Now append the core path entries -
+ this will include the NULL
+ */
+ rc = RegQueryValueEx(newKey, NULL, 0, NULL,
+ (LPBYTE)szCur, &dataSize);
}
/* And set the result - caller must free
If MBCS, it is fine as is. If Unicode, allocate new