Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 76ec53c

Browse files
committed
Subject: Bug in PC/import_nt.c
From: Dan Pierson <[email protected]> To: "Mark Hammond (E-mail)" <[email protected]>, "Guido van Rossum (E-mail)" <[email protected]> Date: Mon, 8 Jun 1998 17:25:07 -0400 RegistryQueryValue requires that its fourth argument be initialized to the length of the buffer being passed in, this wasn't being done. I also split the call and status test into two lines with a local variable so that I could look at the status in the debugger.
1 parent 60f2f0c commit 76ec53c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

PC/import_nt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ FILE *PyWin_FindRegisteredModule( const char *moduleName, struct filedescr **ppF
4545
FILE *fp;
4646
HKEY keyBase = PyWin_IsWin32s() ? HKEY_CLASSES_ROOT : HKEY_LOCAL_MACHINE;
4747
int modNameSize;
48+
long regStat;
4849

4950
// Calculate the size for the sprintf buffer.
5051
// Get the size of the chars only, plus 1 NULL.
@@ -53,7 +54,9 @@ FILE *PyWin_FindRegisteredModule( const char *moduleName, struct filedescr **ppF
5354
moduleKey = alloca(bufSize);
5455
sprintf(moduleKey, "Software\\Python\\PythonCore\\%s\\Modules\\%s%s", PyWin_DLLVersionString, moduleName, debugString);
5556

56-
if (RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize)!=ERROR_SUCCESS)
57+
modNameSize = bufSize;
58+
regStat = RegQueryValue(keyBase, moduleKey, pathBuf, &modNameSize);
59+
if (regStat!=ERROR_SUCCESS)
5760
return NULL;
5861
// use the file extension to locate the type entry.
5962
for (fdp = _PyImport_Filetab; fdp->suffix != NULL; fdp++) {

0 commit comments

Comments
 (0)