diff --git a/usr.sbin/rtsold/cap_script.c b/usr.sbin/rtsold/cap_script.c --- a/usr.sbin/rtsold/cap_script.c +++ b/usr.sbin/rtsold/cap_script.c @@ -162,7 +162,7 @@ const char *const *iargv, *const *scripts; char **argv; size_t argc, i, nscripts; - int fd, status; + int error, fd, status; if (strcmp(cmd, "script_wait") == 0) { /* Wait for the result of a previous "script_run" command. */ @@ -198,8 +198,10 @@ memcpy(argv, iargv, sizeof(*argv) * argc); fd = script_run(argv); + error = errno; + free(argv); if (fd < 0) - return (errno); + return (error); (void)caph_rights_limit(fd, cap_rights_init(&rights, CAP_WRITE)); nvlist_move_descriptor(nvlout, "fd", fd);