Skip to content

Commit abbae5b

Browse files
author
Moshe Zadka
committed
Checking the diff from PC/getpatchp.c 1.22 to 1.23
This fixes many bugs, and was proposed by Thomas Heller. Original log message: ''' Checkin updated version of patch python#103933 . As Thomas says, fixes the bugs python#131064, python#129584, python#127722. See the discussion in bug python#131064 '''
1 parent 67c2759 commit abbae5b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

PC/getpathp.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ extern const char *PyWin_DLLVersionString;
199199
Ex family of functions so it also works with Windows CE.
200200
201201
Returns NULL, or a pointer that should be freed.
202+
203+
XXX - this code is pretty strange, as it used to also
204+
work on Win16, where the buffer sizes werent available
205+
in advance. It could be simplied now Win16/Win32s is dead!
202206
*/
203207

204208
static char *
@@ -279,6 +283,7 @@ getpythonregpath(HKEY keyBase, int skipcore)
279283
}
280284
RegCloseKey(subKey);
281285
}
286+
/* original datasize from RegQueryInfo doesn't include the \0 */
282287
dataBuf = malloc((dataSize+1) * sizeof(TCHAR));
283288
if (dataBuf) {
284289
TCHAR *szCur = dataBuf;
@@ -299,8 +304,11 @@ getpythonregpath(HKEY keyBase, int skipcore)
299304
if (skipcore)
300305
*szCur = '\0';
301306
else {
302-
*(szCur++) = _T(';');
303-
dataSize--;
307+
/* If we have no values, we dont need a ';' */
308+
if (numKeys) {
309+
*(szCur++) = _T(';');
310+
dataSize--;
311+
}
304312
/* Now append the core path entries -
305313
this will include the NULL
306314
*/

0 commit comments

Comments
 (0)