xref: /php-src/ext/zlib/tests/gh16326.phpt (revision d94be24f)
1--TEST--
2GH-16326 (Memory management is broken for bad dictionaries)
3--EXTENSIONS--
4zlib
5--FILE--
6<?php
7try {
8    deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => [" ", ""]]);
9} catch (ValueError $ex) {
10    echo $ex->getMessage(), "\n";
11}
12try {
13    deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => ["hello", "wor\0ld"]]);
14} catch (ValueError $ex) {
15    echo $ex->getMessage(), "\n";
16}
17try {
18    deflate_init(ZLIB_ENCODING_DEFLATE, ["dictionary" => [" ", new stdClass]]);
19} catch (Error $ex) {
20    echo $ex->getMessage(), "\n";
21}
22?>
23--EXPECT--
24deflate_init(): Argument #2 ($options) must not contain empty strings
25deflate_init(): Argument #2 ($options) must not contain strings with null bytes
26Object of class stdClass could not be converted to string
27