lib/x86/stack: fix null dereference
PATCH 1/1 lib/x86/stack: fix null dereference
With gcc 6.2.1 (gcc-6.2.1-2.fc24.x86_64) hitting an assert() in x86 code causes an infinite loop. This is due to a null dereference in backtrace_frame. Let's not do that.
Signed-off-by Andrew Jones <[email protected]>
--- lib/x86/stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/x86/stack.c +1 -1
@@ -13,7 +13,7 @@ int backtrace_frame(const void *frame, const void **return_addrs, int max_depth) } walking =1 ; -for (depth =0 ; depth < max_depth; depth++) { +for (depth =0 ; bp && depth < max_depth; depth++) { return_addrs[depth] = (void *) bp[1 ];if (return_addrs[depth] ==0 )break ;
Signature · 1 line
2.7.4
Quoted 15 lines · Andrew Jones
With gcc 6.2.1 (gcc-6.2.1-2.fc24.x86_64) hitting an
assert()in x86 code causes an infinite loop. This is due to a null dereference inbacktrace_frame. Let's not do that.Signed-off-by Andrew Jones <[email protected]>--- lib/x86/stack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/x86/stack.c +0
-0
lib/x86/stack.c int backtrace_frame(const void *frame, const void **return_addrs, int max_depth) · line 19
Quoted 8 lines
lib/x86/stack.c +1
-1@@ -13,7 +13,7 @@ int backtrace_frame(const void *frame, const void **return_addrs, int max_depth) } walking =1 ; -for (depth =0 ; depth < max_depth; depth++) { +for (depth =0 ; bp && depth < max_depth; depth++) { return_addrs[depth] = (void *) bp[1 ];if (return_addrs[depth] ==0 )break ;
Applied, thanks.
Paolo