From a441dfbc4e339198cf9d27d21579fd04ff8c6e2c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 23 Nov 2014 16:19:46 +0100 Subject: [PATCH] [Hurd] Fix deallocation after proc_getprocinfo call 2014-11-24 Samuel Thibault * gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of elements pi_len by the size of the elements before calling vm_deallocate. (inf_validate_task_sc): Likewise, and properly deallocate the noise array. --- gdb/ChangeLog | 9 +++++++++ gdb/gnu-nat.c | 8 +++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a5881bfbfc..506dc61317 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2014-11-24 Samuel Thibault + + Pushed by Joel Brobecker + * gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of + elements pi_len by the size of the elements before calling + vm_deallocate. + (inf_validate_task_sc): Likewise, and properly deallocate the + noise array. + 2014-11-23 Doug Evans * gdbtypes.c (print_args): Renamed from print_arg_types. Print arg diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index d17a7503c6..6dbf31ddec 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -804,7 +804,8 @@ inf_validate_procinfo (struct inf *inf) inf->nomsg = !!(pi->state & PI_NOMSG); if (inf->nomsg) inf->traced = !!(pi->state & PI_TRACED); - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) pi, + pi_len * sizeof (*(procinfo_t) 0)); if (noise_len > 0) vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len); } @@ -844,9 +845,10 @@ inf_validate_task_sc (struct inf *inf) suspend_count = pi->taskinfo.suspend_count; - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) pi, + pi_len * sizeof (*(procinfo_t) 0)); if (noise_len > 0) - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len); if (inf->task->cur_sc < suspend_count) {