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

Skip to content

Commit 313fcd4

Browse files
committed
PyEnumKey(): Stop including the trailing NUL byte
in the returned string (logic error introduced by recent patch).
1 parent d9ab979 commit 313fcd4

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

PC/_winreg.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,9 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
832832
void *src_buf;
833833
PyBufferProcs *pb = value->ob_type->tp_as_buffer;
834834
if (pb==NULL) {
835-
PyErr_Format(PyExc_TypeError,
835+
PyErr_Format(PyExc_TypeError,
836836
"Objects of type '%s' can not "
837-
"be used as binary registry values",
837+
"be used as binary registry values",
838838
value->ob_type->tp_name);
839839
return FALSE;
840840
}
@@ -1039,14 +1039,13 @@ PyEnumKey(PyObject *self, PyObject *args)
10391039
return NULL;
10401040
if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
10411041
return NULL;
1042-
1042+
10431043
Py_BEGIN_ALLOW_THREADS
10441044
rc = RegEnumKeyEx(hKey, index, tmpbuf, &len, NULL, NULL, NULL, NULL);
10451045
Py_END_ALLOW_THREADS
10461046
if (rc != ERROR_SUCCESS)
10471047
return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx");
1048-
1049-
++len; /* include null terminator */
1048+
10501049
retStr = PyString_FromStringAndSize(tmpbuf, len);
10511050
return retStr; /* can be NULL */
10521051
}

0 commit comments

Comments
 (0)