This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCHv2,Hurd] Fix deallocation after proc_getprocinfo call
- From: Samuel Thibault <samuel dot thibault at gnu dot org>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: bug-hurd at gnu dot org, thomas at codesourcery dot com, gdb-patches at sourceware dot org
- Date: Sun, 23 Nov 2014 16:19:46 +0100
- Subject: Re: [PATCHv2,Hurd] Fix deallocation after proc_getprocinfo call
- Authentication-results: sourceware.org; auth=none
- References: <20141102152537 dot GG2991 at type dot youpi dot perso dot aquilenet dot fr> <20141123074452 dot GC7136 at adacore dot com>
2014-10-02 Samuel Thibault <samuel.thibault@ens-lyon.org>
* 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.
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index d17a750..6dbf31d 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)
{