Skip to content

Commit 5ed8647

Browse files
galpeterrerobika
authored andcommitted
Improve example REPL to exit if there is nothing on the stdin (#3193)
When reading from the stdin a '\n' character or an empty line/file was expected to end the read. However, in case of an input which is not terminated with a newline a buffer overflow will occur. Test case: ```sh $ echo -n "print('a')" | ./build/bin/jerry ``` JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent 2096fba commit 5ed8647

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

jerry-main/main-unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ main (int argc,
861861
/* Read a line */
862862
while (true)
863863
{
864-
if (fread (source_buffer_tail, 1, 1, stdin) != 1 && len == 0)
864+
if (fread (source_buffer_tail, 1, 1, stdin) != 1)
865865
{
866866
is_done = true;
867867
break;

0 commit comments

Comments
 (0)