From a8efdc34834ecc592a79719ccf9fbef76768898b Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Tue, 4 Aug 2026 23:18:00 +0200 Subject: Free lines returned by readline --- src/cli.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cli.c b/src/cli.c index 3fef348..05437a0 100644 --- a/src/cli.c +++ b/src/cli.c @@ -37,16 +37,21 @@ cli_read_input(void) { char *txt = readline(""); - if ((!txt) || (*txt == '\0')) + if ((!txt) || (txt[0] == '\0')) { return DISP_QUIT; - if (*txt == 'q') + } + else if (txt[0] == 'q') { + free(txt); return DISP_QUIT; + } #ifndef NDEBUG if ((*txt == 'r') || (*txt == 'g')) return DISP_RELOAD; #endif - return atoi(txt); + int res = atoi(txt); + free(txt); + return res; } void -- cgit v1.2.3