Skip to content

Commit 116d14a

Browse files
committed
Fix comparison between unsigned subtraction and the value 0
This is resolved by replacing the unsigned subtraction comparison with 0 in the MinimumHeapGrowth stratedgy check to `free_space != size`. Fixes a false positive, "critical" security bug revealed by codeql in code-scanning/#30. Signed-off-by: Winford <winford@object.stream>
1 parent 2ac2041 commit 116d14a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libAtomVM/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ enum MemoryGCResult memory_ensure_free_with_roots(Context *c, size_t size, size_
167167
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space - size > maximum_free_space);
168168
} break;
169169
case MinimumHeapGrowth:
170-
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space - size > 0);
170+
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space > size);
171171
break;
172172
case FibonacciHeapGrowth: {
173173
memory_size = memory_heap_memory_size(&c->heap);

0 commit comments

Comments
 (0)