nm: Fix latent memory leak in show_symbols.
authorMark Wielaard <mark@klomp.org>
Thu, 29 Aug 2019 15:46:52 +0000 (17:46 +0200)
committerMark Wielaard <mark@klomp.org>
Thu, 29 Aug 2019 15:46:52 +0000 (17:46 +0200)
commitdf33285b60290fadefd140ee2fe616f750105d2f
tree43ce2d68e113f7a1398f0031fad8533f5e5903ff
parentbb106065dc6962fabf1c163f18c932650dac6580
nm: Fix latent memory leak in show_symbols.

If there are just a handful of symbols then memory for them is
allocated on the stack, otherwise the memory is malloced. So before
freeing the memory we need to check the number of entries to know if
the memory was heap allocated or not. But since not all entries might
be used we might have decreased the number of entries to the number
we will actually show. Remember the original symbol entries to not
have a memory leak.

Signed-off-by: Mark Wielaard <mark@klomp.org>
src/ChangeLog
src/nm.c