diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp index a9222e0015553..b1f537c0238f8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp @@ -84,7 +84,7 @@ void BufferedStackTrace::Unwind(u32 max_depth, uptr pc, uptr bp, void *context, UnwindSlow(pc, max_depth); // If there are too few frames, the program may be built with // -fno-asynchronous-unwind-tables. Fall back to fast unwinder below. - if (size > 2) + if (size > 2 || size >= max_depth) return; #else UNREACHABLE("slow unwind requested but not available");