Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
maxbachmann authored Feb 28, 2023
commit 799f380cbc93fefc63340de3d747040bd7bbfd56
41 changes: 25 additions & 16 deletions PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,8 @@ winreg_QueryValue_impl(PyObject *module, HKEY key, const Py_UNICODE *sub_key)
PyObject *result = NULL;

if (PySys_Audit("winreg.QueryValue", "nuu",
(Py_ssize_t)key, sub_key, NULL) < 0) {
(Py_ssize_t)key, sub_key, NULL) < 0)
{
return NULL;
}

Expand Down Expand Up @@ -1591,7 +1592,8 @@ winreg_QueryValueEx_impl(PyObject *module, HKEY key, const Py_UNICODE *name)
PyObject *result = NULL;

if (PySys_Audit("winreg.QueryValue", "nuu",
(Py_ssize_t)key, NULL, name) < 0) {
(Py_ssize_t)key, NULL, name) < 0)
{
return NULL;
}

Expand Down Expand Up @@ -1821,32 +1823,39 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key,
DWORD type, PyObject *value)
/*[clinic end generated code: output=811b769a66ae11b7 input=900a9e3990bfb196]*/
{
BYTE *data;
DWORD len;

LONG rc;
BYTE *value = NULL;
DWORD size;
PyObject *result = NULL;

if (!Py2Reg(value, type, &data, &len))
if (!Py2Reg(value_obj, type, &value, &size))
{
if (!PyErr_Occurred())
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
"Could not convert the data to the specified type.");
}
return NULL;
}
if (PySys_Audit("winreg.SetValue", "nunO",
(Py_ssize_t)key, value_name, (Py_ssize_t)type,
value) < 0) {
PyMem_Free(data);
return NULL;
value_obj) < 0)
{
goto exit;
}

Py_BEGIN_ALLOW_THREADS
rc = RegSetValueExW(key, value_name, 0, type, data, len);
rc = RegSetValueExW(key, value_name, 0, type, value, size);
Py_END_ALLOW_THREADS
PyMem_Free(data);
if (rc != ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc,
"RegSetValueEx");
Py_RETURN_NONE;
if (rc == ERROR_SUCCESS) {
result = Py_NewRef(Py_None);
}
else {
PyErr_SetFromWindowsErrWithFunction(rc, "RegSetValueEx");
}

exit:
PyMem_Free(value);
return result;
}

/*[clinic input]
Expand Down