aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2026-08-04 23:18:00 +0200
committerTristan Riehs <tristan.riehs@inria.fr>2026-08-04 23:18:00 +0200
commita8efdc34834ecc592a79719ccf9fbef76768898b (patch)
treeeb4e68ceb44493f447c7f295e575006522c9e9e5 /src
parent6f2e134fa25c768043f6cc38d9ea2dc61b745f7d (diff)
Free lines returned by readline
Diffstat (limited to 'src')
-rw-r--r--src/cli.c11
1 files changed, 8 insertions, 3 deletions
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