Skip to content

Commit

Permalink
cli BUGFIX avoid read on -1 in linenoise
Browse files Browse the repository at this point in the history
  • Loading branch information
lePici authored and michalvasko committed Dec 4, 2024
1 parent 0fab177 commit 4cddd92
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cli/linenoise/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,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 4cddd92

Please sign in to comment.