summaryrefslogtreecommitdiff
path: root/test/simple/test-zlib-dictionary-fail.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-01-22 13:23:46 +0100
committerBen Noordhuis <info@bnoordhuis.nl>2013-01-22 13:34:43 +0100
commitd7bf7ed9935587a6681a090e5d12840f9a60f55e (patch)
treee42875903c67c12f59f3e74bfbd489ec5f8f2d7e /test/simple/test-zlib-dictionary-fail.js
parent1c32eb4ae227f09e0e442ecd0445ec34d85332fe (diff)
downloadnode-d7bf7ed9935587a6681a090e5d12840f9a60f55e.tar.gz
zlib: don't assert on malformed dictionary
Handle Z_DATA_ERROR errors from inflateSetDictionary() gracefully. Fixes the following assertion: node: ../src/node_zlib.cc:167: static void node::ZCtx::Process (uv_work_t*): Assertion `ctx->err_ == 0 && "Failed to set dictionary"' failed. Aborted (core dumped) Fixes #4632.
Diffstat (limited to 'test/simple/test-zlib-dictionary-fail.js')
-rw-r--r--test/simple/test-zlib-dictionary-fail.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/simple/test-zlib-dictionary-fail.js b/test/simple/test-zlib-dictionary-fail.js
index f6d186990..fd35a0192 100644
--- a/test/simple/test-zlib-dictionary-fail.js
+++ b/test/simple/test-zlib-dictionary-fail.js
@@ -34,3 +34,15 @@ var zlib = require('zlib');
// String "test" encoded with dictionary "dict".
stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
})();
+
+// Should raise an error, not trigger an assertion in src/node_zlib.cc
+(function() {
+ var stream = zlib.createInflate({ dictionary: Buffer('fail') });
+
+ stream.on('error', common.mustCall(function(err) {
+ assert(/Bad dictionary/.test(err.message));
+ }));
+
+ // String "test" encoded with dictionary "dict".
+ stream.write(Buffer([0x78,0xBB,0x04,0x09,0x01,0xA5]));
+})();