Skip to content

Commit

Permalink
linenoise BUGFIX avoid read on -1
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvasko committed Dec 4, 2024
1 parent 1c78c9d commit 631ccc5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tools/lint/linenoise/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,11 +1106,14 @@ void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
* STDIN_FILENO and STDOUT_FILENO.
*/
int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt) {
if (stdin_fd == -1) stdin_fd = STDIN_FILENO;
if (stdout_fd == -1) stdout_fd = STDOUT_FILENO;

/* Populate the linenoise state that we pass to functions implementing
* specific editing functionalities. */
l->in_completion = 0;
l->ifd = stdin_fd != -1 ? stdin_fd : STDIN_FILENO;
l->ofd = stdout_fd != -1 ? stdout_fd : STDOUT_FILENO;
l->ifd = stdin_fd;
l->ofd = stdout_fd;
l->buf = buf;
l->buflen = buflen;
l->prompt = prompt;
Expand Down

0 comments on commit 631ccc5

Please sign in to comment.