Fix NULL address check and add docstring to set_uint_at_address

This commit is contained in:
copilot-swe-agent[bot]
2026-06-25 10:39:14 +00:00
committed by GitHub
parent c35ff2e843
commit f6d813dc26

View File

@@ -689,7 +689,10 @@ set_uint_at_address(PyObject *self UNUSED, PyObject *args) {
unsigned int value;
if (!PyArg_ParseTuple(args, "OI", &address_obj, &value)) return NULL;
void *ptr = PyLong_AsVoidPtr(address_obj);
if (ptr == NULL && PyErr_Occurred()) return NULL;
if (ptr == NULL) {
if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, "NULL address is not valid");
return NULL;
}
*((unsigned int*)ptr) = value;
Py_RETURN_NONE;
}
@@ -727,7 +730,7 @@ static PyMethodDef module_methods[] = {
{"timed_debug_print", (PyCFunction)py_timed_debug_print, METH_VARARGS, ""},
{"find_in_memoryview", (PyCFunction)find_in_memoryview, METH_VARARGS, ""},
{"run_at_exit_cleanup_functions", (PyCFunction)py_run_atexit_cleanup_functions, METH_NOARGS, ""},
{"set_uint_at_address", (PyCFunction)set_uint_at_address, METH_VARARGS, ""},
{"set_uint_at_address", (PyCFunction)set_uint_at_address, METH_VARARGS, "Write an unsigned integer value to a memory address"},
#ifdef __APPLE__
METHODB(user_cache_dir, METH_NOARGS),
METHODB(process_group_map, METH_NOARGS),