Fix another memleak in the XNU debugger

This commit is contained in:
pancake 2017-11-04 21:00:18 +01:00
parent e81e153729
commit 9b19ca5793

View file

@ -64,24 +64,23 @@ typedef struct {
/* XXX: right now it just returns the first thread, not the one selected in dbg->tid */
static thread_t getcurthread (RDebug *dbg) {
thread_t th;
thread_array_t threads = NULL;
unsigned int n_threads = 0;
task_t t = pid_to_task (dbg->pid);
if (!t) {
return -1;
}
if (task_threads (t, &threads, &n_threads)) {
if (task_threads (t, &threads, &n_threads) != KERN_SUCCESS) {
return -1;
}
if (n_threads < 1) {
return -1;
if (n_threads > 0) {
memcpy (&th, threads, sizeof (th));
} else {
th = -1;
}
#if 0
if (n_threads > 1) {
eprintf ("THREADS: %d\n", n_threads);
}
#endif
return threads[0];
vm_deallocate (t, (vm_address_t)threads, n_threads * sizeof (thread_act_t));
return th;
}
static xnu_thread_t* get_xnu_thread(RDebug *dbg, int tid) {