From 4a0f78bc4b2d6d507f5ae3b2d8f05d0c0ac14369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Lang=C3=B3?= Date: Mon, 21 Nov 2016 11:28:07 +0100 Subject: [PATCH] Fix fopen call on non-existing files. (#1442) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The main implementation of unix platform hangs, if the engine was built with jerry-libc. Open system call returns with a negative error code if cannot open the file, but fopen must return NULL when error happens. Fixes #1437. JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com --- jerry-libc/target/posix/jerry-libc-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jerry-libc/target/posix/jerry-libc-target.c b/jerry-libc/target/posix/jerry-libc-target.c index 2fb51e630..aac25b531 100644 --- a/jerry-libc/target/posix/jerry-libc-target.c +++ b/jerry-libc/target/posix/jerry-libc-target.c @@ -178,7 +178,7 @@ fopen (const char *path, /**< file path */ long int ret = syscall_3 (SYSCALL_NO (open), (long int) path, flags, access); - return (void *) (uintptr_t) (ret); + return ((ret < 0) ? NULL : (void *) (uintptr_t) (ret)); } /* fopen */ /**