diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2026-08-04 23:18:00 +0200 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2026-08-04 23:18:00 +0200 |
| commit | a8efdc34834ecc592a79719ccf9fbef76768898b (patch) | |
| tree | eb4e68ceb44493f447c7f295e575006522c9e9e5 | |
| parent | 6f2e134fa25c768043f6cc38d9ea2dc61b745f7d (diff) | |
Free lines returned by readline
| -rw-r--r-- | src/cli.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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 |
