--TEST--
Test gzuncompress() function : error conditions
---XFAIL--
-Test will fail until bug #47179 resolved; no error when $length too small
--SKIPIF--
<?php
if (!extension_loaded("zlib")) {
* Alias to functions:
*/
-
-
echo "*** Testing gzuncompress() : error conditions ***\n";
// Zero arguments
echo "\n-- Testing with Unicode string --\n";
var_dump(gzuncompress($data, $length));
-
echo "\n-- Testing with a buffer that is too small --\n";
$short_len = strlen($data) - 1;
$compressed = gzcompress(b"$data");
var_dump(gzuncompress($compressed, $short_len));
-
echo "\n-- Testing with incorrect arguments --\n";
var_dump(gzuncompress(123));
NULL
-- Testing with a buffer that is too small --
-Warning: gzuncompress(): buffer error in %s on line %d
+
+Warning: gzuncompress(): insufficient memory in %s on line %d
bool(false)
-- Testing with incorrect arguments --
Warning: gzuncompress() expects parameter 2 to be long, Unicode string given in %s on line %d
NULL
-===DONE===
\ No newline at end of file
+===DONE===
*buf = NULL;
*len = 0;
- buffer.size = Z->avail_in;
+ buffer.size = (max && (max < Z->avail_in)) ? max : Z->avail_in;
do {
- if ((max && (max < buffer.used)) || !(buffer.aptr = erealloc_recoverable(buffer.data, buffer.size))) {
+ if ((max && (max <= buffer.used)) || !(buffer.aptr = erealloc_recoverable(buffer.data, buffer.size))) {
status = Z_MEM_ERROR;
} else {
buffer.data = buffer.aptr;