Skip to content

Commit 6af7f29

Browse files
committed
refactor: disable dcb encoding when dictionary loading fails
1 parent 5cde633 commit 6af7f29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

brotli.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ static zend_string *php_brotli_output_handler_load_dict(php_brotli_context *ctx)
376376
{
377377
char *file = BROTLI_G(output_compression_dict);
378378
if (!file || strlen(file) == 0) {
379-
BROTLI_G(compression_coding) &= ~PHP_BROTLI_ENCODING_DCB;
380379
return NULL;
381380
}
382381

@@ -419,7 +418,6 @@ static zend_string *php_brotli_output_handler_load_dict(php_brotli_context *ctx)
419418
php_stream_close(stream);
420419

421420
if (!dict) {
422-
BROTLI_G(compression_coding) &= ~PHP_BROTLI_ENCODING_DCB;
423421
return NULL;
424422
}
425423

@@ -457,7 +455,6 @@ static zend_string *php_brotli_output_handler_load_dict(php_brotli_context *ctx)
457455
} else {
458456
php_error_docref(NULL, E_WARNING,
459457
"brotli: not found available-dictionary");
460-
BROTLI_G(compression_coding) &= ~PHP_BROTLI_ENCODING_DCB;
461458
zend_string_release(dict);
462459
dict = NULL;
463460
}
@@ -475,6 +472,9 @@ static int php_brotli_output_handler_context_start(php_brotli_context *ctx)
475472
{
476473
long level = BROTLI_G(output_compression_level);
477474
zend_string *dict = php_brotli_output_handler_load_dict(ctx);
475+
if (dict == NULL) {
476+
BROTLI_G(compression_coding) &= ~PHP_BROTLI_ENCODING_DCB;
477+
}
478478
if (!BROTLI_G(compression_coding)) {
479479
return FAILURE;
480480
}

0 commit comments

Comments
 (0)