This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH,Hurd] Fix deallocation after proc_getprocinfo call
- From: Joel Brobecker <brobecker at adacore dot com>
- To: bug-hurd at gnu dot org, thomas at codesourcery dot com, gdb-patches at sourceware dot org
- Date: Sun, 23 Nov 2014 13:56:29 +0400
- Subject: Re: [PATCH,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> <20141123091347 dot GV4576 at type dot youpi dot perso dot aquilenet dot fr>
> > > - 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));
> >
> > Suggest using "sizeof (struct procinfo)", which I think is better
> > than dereferencing a NULL pointer. This is based on guessing that
> > type procinfo_t is a pointer to struct procinfo, as suggested by
> > the code in inf_validate_procinfo.
>
> Not, that is not the same: struct procinfo has an open array at its end
> (threadinfos[0]), and thus the actually allocated size is variable.
OK. I don't know the code well enough to make any better suggestion.
The above does look unusual to me, but if it works and seems to be
the only correct way, let's go with that.
Should I push your patch?
--
Joel