[Python-checkins] CVS: python/dist/src/PC getpathp.c,1.20,1.21

Mark Hammond python-dev@python.org
Sun, 10 Sep 2000 02:14:56 -0700


Update of /cvsroot/python/python/dist/src/PC
In directory slayer.i.sourceforge.net:/tmp/cvs-serv26024

Modified Files:
	getpathp.c 
Log Message:
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.

Index: getpathp.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/PC/getpathp.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** getpathp.c	2000/09/01 23:29:27	1.20
--- getpathp.c	2000/09/10 09:14:53	1.21
***************
*** 264,268 ****
  			ppPaths[index] = malloc(reqdSize);
  			if (ppPaths[index]) {
! 				RegQueryValueEx(subKey, NULL, 0, NULL, (LPBYTE)ppPaths[index], &reqdSize);
  				dataSize += reqdSize + 1; /* 1 for the ";" */
  			}
--- 264,270 ----
  			ppPaths[index] = malloc(reqdSize);
  			if (ppPaths[index]) {
! 				RegQueryValueEx(subKey, NULL, 0, NULL, 
! 				                (LPBYTE)ppPaths[index], 
! 				                &reqdSize);
  				dataSize += reqdSize + 1; /* 1 for the ";" */
  			}
***************
*** 276,288 ****
  		/* 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 (skipcore)
--- 278,291 ----
  		/* Copy our collected strings */
  		for (index=0;index<numKeys;index++) {
  			if (index > 0) {
  				*(szCur++) = _T(';');
  				dataSize--;
  			}
! 			if (ppPaths[index]) {
! 				int len = _tcslen(ppPaths[index]);
! 				_tcsncpy(szCur, ppPaths[index], len);
! 				szCur += len;
! 				dataSize -= len;
! 			}
  		}
  		if (skipcore)
***************
*** 291,296 ****
  			*(szCur++) = _T(';');
  			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 
--- 294,302 ----
  			*(szCur++) = _T(';');
  			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