From 0164dac3d61f8b81818977ab46488bb884eca4f2 Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Fri, 1 Mar 2024 17:33:04 -0500 Subject: [PATCH] [lib][heap] Fix array index out-of-range argv[] should have at least 3 elements because argv[2] is accessed in line 345. --- lib/heap/heap_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/heap/heap_wrapper.c b/lib/heap/heap_wrapper.c index 2764f4265..ec3aeb305 100644 --- a/lib/heap/heap_wrapper.c +++ b/lib/heap/heap_wrapper.c @@ -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 {