1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

Fix BZ #18084 -- backtrace (..., 0) dumps core on x86.

Other architectures also had bugs, or did unnecessary work.
This commit is contained in:
Paul Pluzhnikov
2015-08-15 11:42:43 -07:00
parent 3cda1b6d56
commit d5dff793af
11 changed files with 57 additions and 16 deletions

View File

@ -111,6 +111,10 @@ int
__backtrace (void **array, int size)
{
struct trace_arg arg = { .array = array, .size = size, .cnt = -1 };
if (size <= 0)
return 0;
#ifdef SHARED
__libc_once_define (static, once);
@ -119,8 +123,7 @@ __backtrace (void **array, int size)
return 0;
#endif
if (size >= 1)
unwind_backtrace (backtrace_helper, &arg);
unwind_backtrace (backtrace_helper, &arg);
if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL)
--arg.cnt;