diff --git a/debug/tst-backtrace2.c b/debug/tst-backtrace2.c index 846ca35..396d743 100644 --- a/debug/tst-backtrace2.c +++ b/debug/tst-backtrace2.c @@ -94,6 +94,12 @@ fn3 (void) NO_INLINE static int do_test (void) { + /* Test BZ #18084. */ + void *buffer[1]; + + if (backtrace (buffer, 0) != 0) + FAIL (); + fn3 (); return ret; } diff --git a/sysdeps/i386/backtrace.c b/sysdeps/i386/backtrace.c index 550234f..a0eff81 100644 --- a/sysdeps/i386/backtrace.c +++ b/sysdeps/i386/backtrace.c @@ -122,8 +122,10 @@ __backtrace (array, size) return 0; #endif - if (size >= 1) - unwind_backtrace (backtrace_helper, &arg); + if (size <= 0) + return 0; + + unwind_backtrace (backtrace_helper, &arg); if (arg.cnt > 1 && arg.array[arg.cnt - 1] == NULL) --arg.cnt;