jani                                     Wed, 09 Dec 2009 20:33:31 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291931

Log:
- Fixed bug #47179 (gzuncompress does not report expcted error)

Bug: http://bugs.php.net/47179 (Open) gzuncompress does not report expcted error
      
Changed paths:
    U   php/php-src/trunk/ext/zlib/tests/gzuncompress_error1.phpt
    U   php/php-src/trunk/ext/zlib/zlib.c

Modified: php/php-src/trunk/ext/zlib/tests/gzuncompress_error1.phpt
===================================================================
--- php/php-src/trunk/ext/zlib/tests/gzuncompress_error1.phpt   2009-12-09 
20:32:13 UTC (rev 291930)
+++ php/php-src/trunk/ext/zlib/tests/gzuncompress_error1.phpt   2009-12-09 
20:33:31 UTC (rev 291931)
@@ -1,7 +1,5 @@
 --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")) {
@@ -16,8 +14,6 @@
  * Alias to functions:
  */

-
-
 echo "*** Testing gzuncompress() : error conditions ***\n";

 // Zero arguments
@@ -34,14 +30,12 @@
 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));

@@ -77,7 +71,8 @@
 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 --
@@ -90,4 +85,4 @@

 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===

Modified: php/php-src/trunk/ext/zlib/zlib.c
===================================================================
--- php/php-src/trunk/ext/zlib/zlib.c   2009-12-09 20:32:13 UTC (rev 291930)
+++ php/php-src/trunk/ext/zlib/zlib.c   2009-12-09 20:33:31 UTC (rev 291931)
@@ -321,10 +321,10 @@
        *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;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to