This is the mail archive of the gdb-testers@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix leak in mdebugread.c


*** TEST RESULTS FOR COMMIT 36cb72375cc371b786ceaec588ec26f8c55ae2ec ***

Author: Pedro Alves <palves@redhat.com>
Branch: master
Commit: 36cb72375cc371b786ceaec588ec26f8c55ae2ec

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'.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]