aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-06-17 13:34:57 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-06-17 13:34:57 -0700
commit95404d0d0ebb71d323fad135e9a9bb9981c12808 (patch)
treeafb2002d8aeaa4814248193190333e8c6984f550
parent7c26bbdb7d3c40d68777cc93f54ebfa5355a48bc (diff)
parent65f3054a90a1275f831a595c84e6fbfb070e7aab (diff)
Merge pull request #2430 from gsathya/bug2235
Bug2235
-rw-r--r--src/library_fs.js3
-rw-r--r--tests/fs/test_emptyPath.c14
-rw-r--r--tests/fs/test_emptyPath.out2
-rw-r--r--tests/test_core.py6
4 files changed, 25 insertions, 0 deletions
diff --git a/src/library_fs.js b/src/library_fs.js
index d825892c..a75dab97 100644
--- a/src/library_fs.js
+++ b/src/library_fs.js
@@ -932,6 +932,9 @@ mergeInto(LibraryManager.library, {
});
},
open: function(path, flags, mode, fd_start, fd_end) {
+ if (path === "") {
+ throw new FS.ErrnoError(ERRNO_CODES.ENOENT);
+ }
flags = typeof flags === 'string' ? FS.modeStringToFlags(flags) : flags;
mode = typeof mode === 'undefined' ? 438 /* 0666 */ : mode;
if ((flags & {{{ cDefine('O_CREAT') }}})) {
diff --git a/tests/fs/test_emptyPath.c b/tests/fs/test_emptyPath.c
new file mode 100644
index 00000000..27d56ea1
--- /dev/null
+++ b/tests/fs/test_emptyPath.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+int main() {
+ FILE* f1 = fopen("s", "r");
+ if (f1 == NULL) {
+ printf("file 's' not found!\n");
+ }
+
+ FILE* f2 = fopen("", "r");
+ if (f2 == NULL) {
+ printf("file '' not found!\n");
+ }
+ return 0;
+}
diff --git a/tests/fs/test_emptyPath.out b/tests/fs/test_emptyPath.out
new file mode 100644
index 00000000..78352877
--- /dev/null
+++ b/tests/fs/test_emptyPath.out
@@ -0,0 +1,2 @@
+file 's' not found!
+file '' not found!
diff --git a/tests/test_core.py b/tests/test_core.py
index 08e3594e..137e5e4a 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -4348,6 +4348,12 @@ def process(filename):
out = path_from_root('tests', 'fs', 'test_writeFile.out')
self.do_run_from_file(src, out)
+ def test_fs_emptyPath(self):
+ if self.emcc_args is None: return self.skip('requires emcc')
+ src = path_from_root('tests', 'fs', 'test_emptyPath.c')
+ out = path_from_root('tests', 'fs', 'test_emptyPath.out')
+ self.do_run_from_file(src, out)
+
def test_fs_append(self):
if self.emcc_args is None: return self.skip('requires emcc')
src = open(path_from_root('tests', 'fs', 'test_append.c'), 'r').read()