Skip to content

Commit 631ccc5

Browse files
committed
linenoise BUGFIX avoid read on -1
1 parent 1c78c9d commit 631ccc5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tools/lint/linenoise/linenoise.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,14 @@ void linenoiseEditDeletePrevWord(struct linenoiseState *l) {
11061106
* STDIN_FILENO and STDOUT_FILENO.
11071107
*/
11081108
int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt) {
1109+
if (stdin_fd == -1) stdin_fd = STDIN_FILENO;
1110+
if (stdout_fd == -1) stdout_fd = STDOUT_FILENO;
1111+
11091112
/* Populate the linenoise state that we pass to functions implementing
11101113
* specific editing functionalities. */
11111114
l->in_completion = 0;
1112-
l->ifd = stdin_fd != -1 ? stdin_fd : STDIN_FILENO;
1113-
l->ofd = stdout_fd != -1 ? stdout_fd : STDOUT_FILENO;
1115+
l->ifd = stdin_fd;
1116+
l->ofd = stdout_fd;
11141117
l->buf = buf;
11151118
l->buflen = buflen;
11161119
l->prompt = prompt;

0 commit comments

Comments
 (0)