| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0a78925 commit ef25033
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,7 +111,12 @@ enum node_zlib_mode { | |||
| 111 | 111 | ||
| 112 | 112 | struct CompressionError { | |
| 113 | 113 | CompressionError(const char* message, const char* code, int err) | |
| 114 | - : message(message), code(code), err(err) {} | ||
| 114 | + : message(message), | ||
| 115 | + code(code), | ||
| 116 | + err(err) { | ||
| 117 | + CHECK_NOT_NULL(message); | ||
| 118 | + } | ||
| 119 | + | ||
| 115 | 120 | CompressionError() = default; | |
| 116 | 121 | ||
| 117 | 122 | const char* message = nullptr; | |
@@ -997,7 +1002,7 @@ CompressionError ZlibContext::Init( | |||
| 997 | 1002 | if (err_ != Z_OK) { | |
| 998 | 1003 | dictionary_.clear(); | |
| 999 | 1004 | mode_ = NONE; | |
| 1000 | - return ErrorForMessage(nullptr); | ||
| 1005 | + return ErrorForMessage("zlib error"); | ||
| 1001 | 1006 | } | |
| 1002 | 1007 | ||
| 1003 | 1008 | return SetDictionary(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,13 @@ const stream = require('stream'); | |||
| 27 | 27 | const fs = require('fs'); | |
| 28 | 28 | const fixtures = require('../common/fixtures'); | |
| 29 | 29 | ||
| 30 | + // Should not segfault. | ||
| 31 | + assert.throws(() => zlib.gzipSync(Buffer.alloc(0), { windowBits: 8 }), { | ||
| 32 | + code: 'ERR_ZLIB_INITIALIZATION_FAILED', | ||
| 33 | + name: 'Error', | ||
| 34 | + message: 'Initialization failed', | ||
| 35 | + }); | ||
| 36 | + | ||
| 30 | 37 | let zlibPairs = [ | |
| 31 | 38 | [zlib.Deflate, zlib.Inflate], | |
| 32 | 39 | [zlib.Gzip, zlib.Gunzip], | |
| Back | FazBrowse Home | New Git URL |
0 commit comments