Fix leak in mdebugread.c
authorPedro Alves <palves@redhat.com>
Thu, 10 Jan 2019 17:52:38 +0000 (17:52 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 10 Jan 2019 17:52:38 +0000 (17:52 +0000)
commit36cb72375cc371b786ceaec588ec26f8c55ae2ec
treec0e9803a737866f7a77956e9181a5b62bac0ed87
parentda584958006fd0a3f3dccd25a0a54fa79a0976bc
Fix leak in mdebugread.c

Coverity points out that all the "continue;" statements in the switch
case in parse_partial_symbols leak STABSTRING.  This is because we
only release STABSTRING at the end of the scope, with:

              if (stabstring
    && stabstring != debug_info->ss + fh->issBase + sh.iss)
  xfree (stabstring);

but that bit of code is skipped if a case in the switch statement ends
with "continue".

Fix this by using gdb::unique_xmalloc_ptr to manage the heap-allocated
version of 'stabsstring'.

I don't know how to test this.

gdb/ChangeLog:
2019-01-10  Pedro Alves  <palves@redhat.com>

* mdebugread.c (parse_partial_symbols): Use
gdb::unique_xmalloc_ptr to manage heap-allocated 'stabsstring'.
gdb/ChangeLog
gdb/mdebugread.c
This page took 0.024586 seconds and 4 git commands to generate.