]> granicus.if.org Git - php/commitdiff
Fixed bug #37341 ($_SERVER in included file is shortened to two entries, if $_ENV...
authorDmitry Stogov <dmitry@php.net>
Wed, 24 May 2006 07:52:58 +0000 (07:52 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 24 May 2006 07:52:58 +0000 (07:52 +0000)
sapi/cgi/cgi_main.c

index e0741ee97baf34c0447c340f194c927e32ae57d4..71deaf07ebe961bca75ec806db8544de1db47820 100644 (file)
@@ -413,14 +413,18 @@ static char *sapi_cgi_read_cookies(TSRMLS_D)
 void cgi_php_import_environment_variables(zval *array_ptr TSRMLS_DC)
 {
        if (PG(http_globals)[TRACK_VARS_ENV] &&
-           array_ptr != PG(http_globals)[TRACK_VARS_ENV]) {
+           array_ptr != PG(http_globals)[TRACK_VARS_ENV] &&
+           Z_TYPE_P(PG(http_globals)[TRACK_VARS_ENV]) == IS_ARRAY &&
+           zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_ENV])) > 0) {
                zval_dtor(array_ptr);
            *array_ptr = *PG(http_globals)[TRACK_VARS_ENV];
            INIT_PZVAL(array_ptr);
            zval_copy_ctor(array_ptr);
            return;
        } else if (PG(http_globals)[TRACK_VARS_SERVER] &&
-               array_ptr != PG(http_globals)[TRACK_VARS_SERVER]) {
+               array_ptr != PG(http_globals)[TRACK_VARS_SERVER] &&
+           Z_TYPE_P(PG(http_globals)[TRACK_VARS_SERVER]) == IS_ARRAY &&
+           zend_hash_num_elements(Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER])) > 0) {
                zval_dtor(array_ptr);
            *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER];
            INIT_PZVAL(array_ptr);