Skip to content

Commit

Permalink
Fix comparison between unsigned subtraction and the value 0
Browse files Browse the repository at this point in the history
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/atomvm#30.

Signed-off-by: Winford <[email protected]>
  • Loading branch information
UncleGrumpy committed Feb 11, 2025
1 parent 2ac2041 commit 116d14a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libAtomVM/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ enum MemoryGCResult memory_ensure_free_with_roots(Context *c, size_t size, size_
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space - size > maximum_free_space);
} break;
case MinimumHeapGrowth:
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space - size > 0);
should_gc = ((alloc_mode == MEMORY_CAN_SHRINK) && free_space > size);
break;
case FibonacciHeapGrowth: {
memory_size = memory_heap_memory_size(&c->heap);
Expand Down

0 comments on commit 116d14a

Please sign in to comment.