diff --git a/Modules/_remote_debugging/subprocess.c b/Modules/_remote_debugging/subprocess.c index cdad75e318be914..056cc6773a88b44 100644 --- a/Modules/_remote_debugging/subprocess.c +++ b/Modules/_remote_debugging/subprocess.c @@ -307,6 +307,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) PyErr_SetString(PyExc_OSError, "Failed to get process count"); goto done; } + n_pids /= sizeof(pid_t); /* Allocate buffer for PIDs (add some slack for new processes) */ int buffer_size = n_pids + 64; @@ -322,6 +323,7 @@ get_child_pids_platform(pid_t target_pid, int recursive, pid_array_t *result) PyErr_SetString(PyExc_OSError, "Failed to list PIDs"); goto done; } + actual /= sizeof(pid_t); /* Build pid -> ppid mapping */ ppids = (pid_t *)PyMem_Malloc(actual * sizeof(pid_t));