This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
RE: [PATCH v2 1/3] make_corefile_notes: have caller free returned memory
- From: "Metzger, Markus T" <markus dot t dot metzger at intel dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: "palves at redhat dot com" <palves at redhat dot com>, "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Tue, 24 Jun 2014 14:17:20 +0000
- Subject: RE: [PATCH v2 1/3] make_corefile_notes: have caller free returned memory
- Authentication-results: sourceware.org; auth=none
- References: <1403599872-25299-1-git-send-email-markus dot t dot metzger at intel dot com> <87ionq4e2l dot fsf at fleche dot redhat dot com>
> -----Original Message-----
> From: gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] On Behalf Of Tom Tromey
> Sent: Tuesday, June 24, 2014 3:45 PM
> To: Metzger, Markus T
> Cc: palves@redhat.com; gdb-patches@sourceware.org
> Subject: Re: [PATCH v2 1/3] make_corefile_notes: have caller free returned
> memory
>
> >>>>> "Markus" == Markus Metzger <markus.t.metzger@intel.com> writes:
>
> Markus> if (note_data == NULL || note_size == 0)
> Markus> error (_("Target does not support core file generation."));
>
> Markus> + cleanup = make_cleanup (xfree, note_data);
>
> I wonder if it is possible for note_data!=NULL but note_size==0.
I don't know. I have not found such a case, but that only means
that I have not looked hard enough.
I found a case where note_data == NULL but note_size could be > 0
in linux_spu_make_corefile_notes in linux-tdep.c, which is similarly
odd.
Other code in the same file is only checking note_data, not note_size.
> If it is possible, then the cleanup ought to be moved earlier.
> (FWIW it's ok to have an xfree cleanup with a NULL argument.)
I'll do that. Thanks for pointing out this bug.
> Or if it is not possible, then I suppose the code just above is in
> error... not your problem but if you happen to know, I would like to fix
> it up.
Replacing note_data and note_size with struct buffer would be nice,
but the change would be quite big, I'm afraid.
Regards,
Markus.
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen, Deutschland
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Christian Lamprechter, Hannes Schwaderer, Douglas Lusk
Registergericht: Muenchen HRB 47456
Ust.-IdNr./VAT Registration No.: DE129385895
Citibank Frankfurt a.M. (BLZ 502 109 00) 600119052