Skip to content

Commit

Permalink
[lib][heap] Fix array index out-of-range
Browse files Browse the repository at this point in the history
argv[] should have at least 3 elements because argv[2] is accessed in line 345.
  • Loading branch information
szsam authored Mar 1, 2024
1 parent 679fbb6 commit 0164dac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/heap/heap_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ static int cmd_heap(int argc, const console_cmd_args *argv) {
void *ptr = realloc(argv[2].p, argv[3].u);
printf("realloc returns %p\n", ptr);
} else if (strcmp(argv[1].str, "free") == 0) {
if (argc < 2) goto notenoughargs;
if (argc < 3) goto notenoughargs;

free(argv[2].p);
} else {
Expand Down

0 comments on commit 0164dac

Please sign in to comment.