Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a key handle leak in :func:`winreg.CreateKey`,
:func:`winreg.CreateKeyEx` and :func:`winreg.OpenKey` when the
``winreg.OpenKey/result`` audit hook fails.
3 changes: 3 additions & 0 deletions PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ winreg_CreateKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key)
}
if (PySys_Audit("winreg.OpenKey/result", "n",
(Py_ssize_t)retKey) < 0) {
RegCloseKey(retKey);
return NULL;
}
return retKey;
Expand Down Expand Up @@ -952,6 +953,7 @@ winreg_CreateKeyEx_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
}
if (PySys_Audit("winreg.OpenKey/result", "n",
(Py_ssize_t)retKey) < 0) {
RegCloseKey(retKey);
return NULL;
}
return retKey;
Expand Down Expand Up @@ -1398,6 +1400,7 @@ winreg_OpenKey_impl(PyObject *module, HKEY key, const wchar_t *sub_key,
}
if (PySys_Audit("winreg.OpenKey/result", "n",
(Py_ssize_t)retKey) < 0) {
RegCloseKey(retKey);
return NULL;
}
return retKey;
Expand Down
Loading