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>
diff --git a/src/nm.c b/src/nm.c
index da1350b..7f6cf2a 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -1438,6 +1438,7 @@
   free (demangle_buffer);
 #endif
   /* Now we know the exact number.  */
+  size_t nentries_orig = nentries;
   nentries = nentries_used;
 
   /* Sort the entries according to the users wishes.  */
@@ -1472,7 +1473,7 @@
     }
 
   /* Free all memory.  */
-  if (nentries * sizeof (sym_mem[0]) >= MAX_STACK_ALLOC)
+  if (nentries_orig * sizeof (sym_mem[0]) >= MAX_STACK_ALLOC)
     free (sym_mem);
 
   obstack_free (&whereob, NULL);