File tree Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Expand file tree Collapse file tree 2 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Memory leak when passing a dictionary with invalid encoding
3+ --EXTENSIONS--
4+ zlib
5+ --FILE--
6+ <?php
7+ try {
8+ inflate_init (123456 , ["dictionary " => "dict " ]);
9+ } catch (ValueError $ e ) {
10+ echo $ e ->getMessage (), "\n" ;
11+ }
12+ try {
13+ deflate_init (123456 , ["dictionary " => "dict " ]);
14+ } catch (ValueError $ e ) {
15+ echo $ e ->getMessage (), "\n" ;
16+ }
17+ ?>
18+ --EXPECT--
19+ Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE
20+ deflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
Original file line number Diff line number Diff line change @@ -880,10 +880,6 @@ PHP_FUNCTION(inflate_init)
880880 RETURN_THROWS ();
881881 }
882882
883- if (!zlib_create_dictionary_string (options , & dict , & dictlen )) {
884- RETURN_THROWS ();
885- }
886-
887883 switch (encoding ) {
888884 case PHP_ZLIB_ENCODING_RAW :
889885 case PHP_ZLIB_ENCODING_GZIP :
@@ -894,6 +890,10 @@ PHP_FUNCTION(inflate_init)
894890 RETURN_THROWS ();
895891 }
896892
893+ if (!zlib_create_dictionary_string (options , & dict , & dictlen )) {
894+ RETURN_THROWS ();
895+ }
896+
897897 object_init_ex (return_value , inflate_context_ce );
898898 ctx = Z_INFLATE_CONTEXT_P (return_value );
899899
@@ -1133,10 +1133,6 @@ PHP_FUNCTION(deflate_init)
11331133 RETURN_THROWS ();
11341134 }
11351135
1136- if (!zlib_create_dictionary_string (options , & dict , & dictlen )) {
1137- RETURN_THROWS ();
1138- }
1139-
11401136 switch (encoding ) {
11411137 case PHP_ZLIB_ENCODING_RAW :
11421138 case PHP_ZLIB_ENCODING_GZIP :
@@ -1147,6 +1143,10 @@ PHP_FUNCTION(deflate_init)
11471143 RETURN_THROWS ();
11481144 }
11491145
1146+ if (!zlib_create_dictionary_string (options , & dict , & dictlen )) {
1147+ RETURN_THROWS ();
1148+ }
1149+
11501150 object_init_ex (return_value , deflate_context_ce );
11511151 ctx = Z_DEFLATE_CONTEXT_P (return_value );
11521152
You can’t perform that action at this time.
0 commit comments