mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 06:55:06 -05:00
client: fix memory leak of empty readline() string
This commit is contained in:
3
client.c
3
client.c
@@ -125,12 +125,11 @@ read_line(void)
|
|||||||
strncpy(line, cmd, sizeof(line) - 1);
|
strncpy(line, cmd, sizeof(line) - 1);
|
||||||
line[sizeof(line) - 1] = '\0';
|
line[sizeof(line) - 1] = '\0';
|
||||||
add_history(cmd);
|
add_history(cmd);
|
||||||
/* free the buffer allocated by readline */
|
|
||||||
Free(cmd);
|
|
||||||
} else {
|
} else {
|
||||||
/* simulate the user has entered an empty line */
|
/* simulate the user has entered an empty line */
|
||||||
*line = '\0';
|
*line = '\0';
|
||||||
}
|
}
|
||||||
|
Free(cmd);
|
||||||
return( line );
|
return( line );
|
||||||
#else
|
#else
|
||||||
printf("%s", prompt);
|
printf("%s", prompt);
|
||||||
|
|||||||
Reference in New Issue
Block a user