forked from espressif/esp-idf
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
This commit is contained in:
committed by
Ivan Grokhotkov
parent
4d53c137e6
commit
dfd4227e7a
@@ -979,11 +979,11 @@ char *linenoise(const char *prompt) {
|
|||||||
} else {
|
} else {
|
||||||
count = linenoiseDumb(buf, LINENOISE_MAX_LINE, prompt);
|
count = linenoiseDumb(buf, LINENOISE_MAX_LINE, prompt);
|
||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count >= 0) {
|
||||||
sanitize(buf);
|
sanitize(buf);
|
||||||
count = strlen(buf);
|
count = strlen(buf);
|
||||||
}
|
}
|
||||||
if (count <= 0) {
|
if (count < 0) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user