From a65592778b5cb6adde3ab53ebe758c4d875a0d79 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sat, 27 Apr 2024 08:22:01 -0400 Subject: kernel: kern_exec: Fix argp resize logic Signed-off-by: Ian Moffett --- sys/kern/kern_exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index bcd7a2e..0386ffd 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -61,6 +61,7 @@ exec_get_args(char **argv, struct exec_args *res) { const size_t ARG_LEN = sizeof(char) * ARG_MAX; char *argp = NULL; + void *tmp; struct proc *td; size_t argp_len = 0; @@ -89,11 +90,12 @@ exec_get_args(char **argv, struct exec_args *res) copyin((uintptr_t)++argv, &argp, sizeof(char *)); /* Try to resize the argp buffer */ - res->argp = dynrealloc(res->argp, ARG_LEN * (argp_len + 1)); - if (res->argp == NULL) { + tmp = dynrealloc(res->argp, ARG_LEN * (argp_len + 1)); + if (tmp == NULL) { dynfree(res->argp); return -ENOMEM; } + res->argp = tmp; } return 0; -- cgit v1.2.3