From: pgen Date: Sun, 13 Apr 2025 21:18:39 +0000 (+0200) Subject: Check scanf return value X-Git-Url: https://repo.or.cz/smenu.git/commitdiff_plain/06cd24b9daeb4f251fc08fd41a7f1b728d8872e5 Check scanf return value --- diff --git a/smenu.c b/smenu.c index e48e980..03fe5ff 100755 --- a/smenu.c +++ b/smenu.c @@ -13918,6 +13918,8 @@ main(int argc, char *argv[]) /* ''''''''''''''''''''''''''''''''''''''''''''''' */ while (1) { + int n = 0; + /* Fast reading until an ESC or the end of input is found. */ /* """"""""""""""""""""""""""""""""""""""""""""""""""""""" */ while ((c = my_fgetc(stdin)) != EOF && c != 0x1b) @@ -13933,8 +13935,8 @@ main(int argc, char *argv[]) /* Read the 5 next characters to look for the */ /* ending bracket "[201~". */ /* """""""""""""""""""""""""""""""""""""""""" */ - scanf("%5c", eb); - if (memcmp("[201~", eb, 5) == 0) + n = scanf("%5c", eb); + if (n == 5 && memcmp("[201~", eb, 5) == 0) break; } }