0023-skill: Fix getline() usage.

man getline: "If *lineptr is set to NULL and *n is set 0 before the
call, then getline() will allocate a buffer for storing the line. This
buffer should be freed by the user program even if getline() failed."
This commit is contained in:
Qualys Security Advisory - committed by Craig Small
parent c704460c7d
commit fa7ea000ce

View File

@ -178,8 +178,10 @@ static int ask_user(struct pids_stack *stack)
PIDS_GETINT(PID),
PIDS_GETSTR(CMD));
fflush(stdout);
if (getline(&buf, &len, stdin) == -1)
if (getline(&buf, &len, stdin) == -1) {
free(buf);
return 0;
}
if (rpmatch(buf) < 1) {
free(buf);
return 0;