]> granicus.if.org Git - php/commitdiff
avoid duplicate array_init
authorMichael Wallner <mike@php.net>
Thu, 22 Jan 2015 09:12:06 +0000 (10:12 +0100)
committerMichael Wallner <mike@php.net>
Thu, 22 Jan 2015 09:16:38 +0000 (10:16 +0100)
custom request body handling firing the rfc1867 handler after the
environment has been hashed might create a memory leak by calling
array_init() twice on PG(http_globals)[TRACK_VARS_FILES]

main/rfc1867.c

index 58617d4f6d5197d259965a235815d573893b4f54..a1ba99f08cbc85b68a0f4403cb36019a19e70728 100644 (file)
@@ -769,7 +769,10 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
        zend_hash_init(uploaded_files, 8, NULL, free_filename, 0);
        SG(rfc1867_uploaded_files) = uploaded_files;
 
-       array_init(&PG(http_globals)[TRACK_VARS_FILES]);
+       if (Z_TYPE(PG(http_globals)[TRACK_VARS_FILES]) != IS_ARRAY) {
+               /* php_auto_globals_create_files() might have already done that */
+               array_init(&PG(http_globals)[TRACK_VARS_FILES]);
+       }
 
        zend_llist_init(&header, sizeof(mime_header_entry), (llist_dtor_func_t) php_free_hdr_entry, 0);