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 01e8ae2..ad3bfb7 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 acd1257..6872943 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);