From dfd4227e7a3ec33dc7dbf77254928c36cca7db89 Mon Sep 17 00:00:00 2001 From: MadnessASAP Date: Thu, 12 Mar 2020 14:57:27 -0700 Subject: [PATCH] Don't return NULL on 0 length input A 0 length string is still a valid input and should be treated as such, a NULL return should be reserved for when errors occur during line editing or EOF is reached. Merges https://github.com/espressif/esp-idf/pull/4926 --- components/console/linenoise/linenoise.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/console/linenoise/linenoise.c b/components/console/linenoise/linenoise.c index f78e238af5..3b2e1c18e7 100644 --- a/components/console/linenoise/linenoise.c +++ b/components/console/linenoise/linenoise.c @@ -979,11 +979,11 @@ char *linenoise(const char *prompt) { } else { count = linenoiseDumb(buf, LINENOISE_MAX_LINE, prompt); } - if (count > 0) { + if (count >= 0) { sanitize(buf); count = strlen(buf); } - if (count <= 0) { + if (count < 0) { free(buf); return NULL; }