aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-26 10:46:32 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-26 10:46:32 -0800
commit4c015a33bc5ed8b4e7f9ef7c80e467cce8af5ad6 (patch)
treeb090998f9135ad06383eb2a2a5b312cabbeb5a68 /src
parent01efb0bfc550ed1e4ebd4cfc2c617dea83026029 (diff)
parentfee89ee4a91f0d1eed465ca785b5353f02913ab4 (diff)
Merge pull request #2157 from rfk/rfk/fileno-error-reporting
Ensure that fileno() returns -1 when given an invalid file pointer.
Diffstat (limited to 'src')
-rw-r--r--src/library.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index 18a794fd..cd451c57 100644
--- a/src/library.js
+++ b/src/library.js
@@ -2420,7 +2420,9 @@ LibraryManager.library = {
fileno: function(stream) {
// int fileno(FILE *stream);
// http://pubs.opengroup.org/onlinepubs/000095399/functions/fileno.html
- return FS.getStreamFromPtr(stream).fd;
+ stream = FS.getStreamFromPtr(stream);
+ if (!stream) return -1;
+ return stream.fd;
},
ftrylockfile: function() {
// int ftrylockfile(FILE *file);