JSValue ret, options;
z_stream stream;
njs_chb_t chain;
+ njs_bool_t initialized;
qjs_bytes_t bytes, dictionary;
chunk_size = NJS_ZLIB_CHUNK_SIZE;
dictionary.length = 0;
dictionary_copy = NULL;
dictionary_length = 0;
- stream.opaque = NULL;
+ initialized = 0;
options = argv[1];
goto fail;
}
+ initialized = 1;
+
if (dictionary_copy != NULL) {
rc = deflateSetDictionary(&stream, dictionary_copy, dictionary_length);
if (rc != Z_OK) {
js_free(ctx, dictionary_copy);
- if (stream.opaque != NULL) {
+ if (initialized) {
deflateEnd(&stream);
}
JSValue ret, options;
z_stream stream;
njs_chb_t chain;
+ njs_bool_t initialized;
qjs_bytes_t bytes, dictionary;
chunk_size = NJS_ZLIB_CHUNK_SIZE;
dictionary.length = 0;
dictionary_copy = NULL;
dictionary_length = 0;
- stream.opaque = NULL;
+ initialized = 0;
options = argv[1];
goto fail;
}
+ initialized = 1;
+
if (dictionary_copy != NULL) {
rc = inflateSetDictionary(&stream, dictionary_copy, dictionary_length);
if (rc != Z_OK) {
}
rc = inflateEnd(&stream);
+ initialized = 0;
+
if (njs_slow_path(rc != Z_OK)) {
qjs_throw_error(ctx, "inflateEnd() failed");
goto fail;
qjs_bytes_free(ctx, &dictionary);
}
- if (stream.opaque != NULL) {
+ if (initialized) {
inflateEnd(&stream);
}