diff mbox

[2/3] solib_target_free_so memory leak

Message ID 20191224122452.1668-2-ssbssa@yahoo.de
State New
Headers show

Commit Message

Doug Evans via gdb-patches Dec. 24, 2019, 12:24 p.m. UTC
gdb/ChangeLog:

2019-12-24  Hannes Domani  <ssbssa@yahoo.de>

	* solib-target.c (solib_target_free_so): Free li->offsets.
---
 gdb/solib-target.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Doug Evans via gdb-patches Dec. 26, 2019, 10:55 p.m. UTC | #1
On Tue, Dec 24, 2019 at 1:25 PM Hannes Domani via gdb-patches
<gdb-patches@sourceware.org> wrote:
>
> gdb/ChangeLog:
>
> 2019-12-24  Hannes Domani  <ssbssa@yahoo.de>
>
>         * solib-target.c (solib_target_free_so): Free li->offsets.
> ---
>  gdb/solib-target.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/gdb/solib-target.c b/gdb/solib-target.c
> index 2b473d6066..52e2a6068b 100644
> --- a/gdb/solib-target.c
> +++ b/gdb/solib-target.c
> @@ -293,6 +293,7 @@ solib_target_free_so (struct so_list *so)
>
>    gdb_assert (li->name.empty ());
>
> +  xfree (li->offsets);
>    delete li;

Maybe a better fix would be to change offsets to be a unique_xmalloc_ptr?

Christian
Tom Tromey Jan. 3, 2020, 4:41 p.m. UTC | #2
>>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:

>> +  xfree (li->offsets);
>> delete li;

Christian> Maybe a better fix would be to change offsets to be a
Christian> unique_xmalloc_ptr?

Makes sense to me.

thanks,
Tom
Doug Evans via gdb-patches Jan. 3, 2020, 4:47 p.m. UTC | #3
Am Freitag, 3. Januar 2020, 17:41:21 MEZ hat Tom Tromey <tom@tromey.com> Folgendes geschrieben:

> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
>
> >> +  xfree (li->offsets);
> >> delete li;
>
>
> Christian> Maybe a better fix would be to change offsets to be a
> Christian> unique_xmalloc_ptr?
>
> Makes sense to me.

I've sent a v2 for this here:
https://sourceware.org/ml/gdb-patches/2019-12/msg01034.html


Regards
Hannes Domani
diff mbox

Patch

diff --git a/gdb/solib-target.c b/gdb/solib-target.c
index 2b473d6066..52e2a6068b 100644
--- a/gdb/solib-target.c
+++ b/gdb/solib-target.c
@@ -293,6 +293,7 @@  solib_target_free_so (struct so_list *so)
 
   gdb_assert (li->name.empty ());
 
+  xfree (li->offsets);
   delete li;
 }