[Hurd] Fix deallocation after proc_getprocinfo call
authorSamuel Thibault <samuel.thibault@gnu.org>
Sun, 23 Nov 2014 15:19:46 +0000 (16:19 +0100)
committerJoel Brobecker <brobecker@adacore.com>
Mon, 24 Nov 2014 09:28:03 +0000 (13:28 +0400)
2014-11-24  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.

gdb/ChangeLog
gdb/gnu-nat.c

index a5881bfbfc07f47ad40ef7c0d94b70e53ba5a086..506dc613175c5c4478369ef2c8d048e45a83f60b 100644 (file)
@@ -1,3 +1,12 @@
+2014-11-24  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+       Pushed by Joel Brobecker  <brobecker@adacore.com>
+       * 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  <xdje42@gmail.com>
 
        * gdbtypes.c (print_args): Renamed from print_arg_types.  Print arg
index d17a7503c60b57830dda515f16caa9b0006d8142..6dbf31ddec479a253dc31dc0ce21b9b0bbd607ac 100644 (file)
@@ -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)
     {