diff options
author | Ryan Kelly <ryan@rfk.id.au> | 2014-02-25 17:15:58 +1100 |
---|---|---|
committer | Ryan Kelly <ryan@rfk.id.au> | 2014-02-26 15:32:44 +1100 |
commit | fee89ee4a91f0d1eed465ca785b5353f02913ab4 (patch) | |
tree | 48574e32a8f164530db45b32b3e3365e48050e67 /src | |
parent | 80de5f33b5f3ce2b7d938b2f1a1909c1cca81733 (diff) |
Ensure that fileno() returns -1 when given an invalid file pointer.
Diffstat (limited to 'src')
-rw-r--r-- | src/library.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js index 5df5ff20..b9571a73 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); |