aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-01-10 01:02:24 +0000
committerUlrich Drepper <drepper@redhat.com>2001-01-10 01:02:24 +0000
commit88d88a58d71d7241c8100fc28b449815018082bc (patch)
treec3b86878fd36afc595ad065be2dfe3583005187b /sysdeps
parent4ab5b7b53f9b1a10b0f7bde05ee84067052602dc (diff)
downloadglibc-88d88a58d71d7241c8100fc28b449815018082bc.tar
glibc-88d88a58d71d7241c8100fc28b449815018082bc.tar.gz
glibc-88d88a58d71d7241c8100fc28b449815018082bc.tar.bz2
glibc-88d88a58d71d7241c8100fc28b449815018082bc.zip
Update.
* sysdeps/generic/elf/backtracesyms.c (__backtrace_symbols): Minimal cleanups. Add assert to ensure memory handling is correct.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/elf/backtracesyms.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sysdeps/generic/elf/backtracesyms.c b/sysdeps/generic/elf/backtracesyms.c
index 0419773d40..2f6208fb8e 100644
--- a/sysdeps/generic/elf/backtracesyms.c
+++ b/sysdeps/generic/elf/backtracesyms.c
@@ -1,5 +1,5 @@
/* Return list with names for address in backtrace.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -18,6 +18,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <assert.h>
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
@@ -50,7 +51,7 @@ __backtrace_symbols (array, size)
status[cnt] = _dl_addr (array[cnt], &info[cnt]);
if (status[cnt] && info[cnt].dli_fname && info[cnt].dli_fname[0] != '\0')
/* We have some info, compute the length of the string which will be
- "<fct-name>(<sym-name>)[+offset]. */
+ "<file-name>(<sym-name>) [+offset]. */
total += (strlen (info[cnt].dli_fname ?: "")
+ (info[cnt].dli_sname
? strlen (info[cnt].dli_sname) + 3 + WORD_WIDTH + 3
@@ -61,7 +62,7 @@ __backtrace_symbols (array, size)
}
/* Allocate memory for the result. */
- result = malloc (size * sizeof (char *) + total);
+ result = (char **) malloc (size * sizeof (char *) + total);
if (result != NULL)
{
char *last = (char *) (result + size);
@@ -93,6 +94,7 @@ __backtrace_symbols (array, size)
else
last += 1 + sprintf (last, "[%p]", array[cnt]);
}
+ assert (last <= (char *) result + size * sizeof (char *) + total);
}
return result;