From 0f951e2d72606854ce2689f201332f551a5a2b81 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Fri, 31 May 2024 23:23:17 +0900 Subject: Check user input before using it --- src/calculer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/calculer.c b/src/calculer.c index 0c9fe8b..2d6c973 100644 --- a/src/calculer.c +++ b/src/calculer.c @@ -81,7 +81,7 @@ main(void) sprintf(prompt, "%d + %d = ", x, y); input = linenoise(prompt); - if (strcmp(input, "q") == 0) + if ((!input) || (*input == '\0')) { free(input); fclose(logfile); -- cgit v1.2.3