diff --git a/libs/gib/gib_interpret.c b/libs/gib/gib_interpret.c index ee0c659ec..fc9eedfc1 100644 --- a/libs/gib/gib_interpret.c +++ b/libs/gib/gib_interpret.c @@ -125,7 +125,10 @@ GIB_Interpret_Inst (char *inst) if (ret) return ret; gib_argc = 0; - for (i = 0; buffer3[i] != ' '; i++); + for (i = 0; buffer3[i] != ' '; i++) + if (buffer3[i] == '\0') + return GIB_E_PARSE; + gib_argv[0] = malloc (i + 1); strncpy (gib_argv[0], buffer3, i); gib_argv[0][i] = 0; diff --git a/libs/gib/gib_stack.c b/libs/gib/gib_stack.c index 026aef4b5..bb3a25586 100644 --- a/libs/gib/gib_stack.c +++ b/libs/gib/gib_stack.c @@ -38,7 +38,7 @@ GIB_InStack_Push (gib_inst_t * instruction, int argc, char **argv) gib_instack = realloc (gib_instack, sizeof (gib_instack_t) * (gib_insp + 1)); - gib_instack[gib_insp].argv = malloc (argc + 1); + gib_instack[gib_insp].argv = malloc ((argc + 1) * sizeof(char *)); for (i = 0; i <= argc; i++) { gib_instack[gib_insp].argv[i] = malloc (strlen (argv[i]) + 1);