fix Bug #15497 HttpInflateStream::finish segfaults when passing NULL
authorMichael Wallner <mike@php.net>
Mon, 12 Jan 2009 10:03:16 +0000 (10:03 +0000)
committerMichael Wallner <mike@php.net>
Mon, 12 Jan 2009 10:03:16 +0000 (10:03 +0000)
http_deflatestream_object.c
http_inflatestream_object.c

index 01e8ae2c8e7058afb7aacfb972909bd7b1515d01..ad3bfb765a55afe58899a7d2949571fd21fc81cd 100644 (file)
@@ -242,8 +242,10 @@ PHP_METHOD(HttpDeflateStream, flush)
                        STR_FREE(encoded);
                        updated_len += encoded_len;
                        RETURN_STRINGL(updated, updated_len, 0);
-               } else {
+               } else if (encoded) {
                        RETVAL_STRINGL(encoded, encoded_len, 0);
+               } else {
+                       RETVAL_NULL();
                }
        } else {
                RETVAL_FALSE;
index acd1257e03332db22fda5dd71e296f12cbbdc960..68729436ee78c78d1c0abf02e08fb6b646c4f419 100644 (file)
@@ -263,9 +263,11 @@ PHP_METHOD(HttpInflateStream, finish)
                        STR_FREE(decoded);
                        updated_len += decoded_len;
                        RETVAL_STRINGL(updated, updated_len, 0);
-               } else {
+               } else if (decoded) {
                        STR_FREE(updated);
                        RETVAL_STRINGL(decoded, decoded_len, 0);
+               } else {
+                       RETVAL_NULL();
                }
        } else {
                STR_FREE(updated);