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:
4
skill.c
4
skill.c
@@ -178,8 +178,10 @@ static int ask_user(struct pids_stack *stack)
|
|||||||
PIDS_GETINT(PID),
|
PIDS_GETINT(PID),
|
||||||
PIDS_GETSTR(CMD));
|
PIDS_GETSTR(CMD));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (getline(&buf, &len, stdin) == -1)
|
if (getline(&buf, &len, stdin) == -1) {
|
||||||
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (rpmatch(buf) < 1) {
|
if (rpmatch(buf) < 1) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user