[lib][heap] Fix array index out-of-range

argv[] should have at least 3 elements because argv[2] is accessed in line 345.
This commit is contained in:
Mingjie Shen
2024-03-01 17:33:04 -05:00
committed by Travis Geiselbrecht
parent 679fbb6e96
commit ed2a3a754d

View File

@@ -340,7 +340,7 @@ usage:
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 {