Skip to content

Commit 85c0873

Browse files
memtrace: Fix underflow when stack_depth < FRAMES_TO_SKIP (#873)
Co-authored-by: Dmitriy Musatkin <[email protected]>
1 parent 5038bc1 commit 85c0873

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/memtrace.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ static void s_alloc_tracer_track(struct alloc_tracer *tracer, void *ptr, size_t
134134
/* capture stack frames, skip 2 for this function and the allocation vtable function */
135135
AWS_VARIABLE_LENGTH_ARRAY(void *, stack_frames, (FRAMES_TO_SKIP + tracer->frames_per_stack));
136136
size_t stack_depth = aws_backtrace(stack_frames, FRAMES_TO_SKIP + tracer->frames_per_stack);
137-
if (stack_depth) {
137+
if (stack_depth >= FRAMES_TO_SKIP) {
138138
/* hash the stack pointers */
139139
struct aws_byte_cursor stack_cursor =
140140
aws_byte_cursor_from_array(stack_frames, stack_depth * sizeof(void *));

0 commit comments

Comments
 (0)