]> granicus.if.org Git - php/commitdiff
Fixed memory leaks
authorDmitry Stogov <dmitry@php.net>
Tue, 18 Apr 2006 06:58:54 +0000 (06:58 +0000)
committerDmitry Stogov <dmitry@php.net>
Tue, 18 Apr 2006 06:58:54 +0000 (06:58 +0000)
main/php_variables.c
sapi/cgi/cgi_main.c

index 50981b61b45bc9ab1b9db815c43960b6ac1eeb70..5363134ad0aad7843a8f72fcb0c17987c2b91130 100644 (file)
@@ -627,10 +627,8 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
                return;
        }
        
-       ALLOC_ZVAL(arr);
+       ALLOC_INIT_ZVAL(arr);
        array_init(arr);
-       arr->is_ref = 0;
-       arr->refcount = 0;
 
        /* Prepare argv */
        if (SG(request_info).argc) { /* are we in cli sapi? */
@@ -670,15 +668,13 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
        }
 
        /* prepare argc */
-       ALLOC_ZVAL(argc);
+       ALLOC_INIT_ZVAL(argc);
        if (SG(request_info).argc) {
                Z_LVAL_P(argc) = SG(request_info).argc;
        } else {
                Z_LVAL_P(argc) = count;
        }
        Z_TYPE_P(argc) = IS_LONG;
-       argc->is_ref = 0;
-       argc->refcount = 0;
 
        if (SG(request_info).argc) {
                arr->refcount++;
@@ -692,6 +688,8 @@ static void php_build_argv(char *s, zval *track_vars_array TSRMLS_DC)
                zend_hash_update(Z_ARRVAL_P(track_vars_array), "argv", sizeof("argv"), &arr, sizeof(zval *), NULL);
                zend_hash_update(Z_ARRVAL_P(track_vars_array), "argc", sizeof("argc"), &argc, sizeof(zval *), NULL);
        }
+       zval_ptr_dtor(&arr);
+       zval_ptr_dtor(&argc);
 }
 /* }}} */
 
index 61983df755e63c32ba55303031d5ab01642c58c5..b01902f39a7ff2c398643a096956d64fbee60d89 100644 (file)
@@ -412,12 +412,16 @@ 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]) {
+               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]) {
+               zval_dtor(array_ptr);
            *array_ptr = *PG(http_globals)[TRACK_VARS_SERVER];
+           INIT_PZVAL(array_ptr);
            zval_copy_ctor(array_ptr);
            return;
        }