diff options
author | Dmitry Stogov <dmitry@php.net> | 2006-04-18 06:58:43 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2006-04-18 06:58:43 +0000 |
commit | 73e4913cca4561ec427d6f024210e307ba620d0e (patch) | |
tree | f88dd344a1b893755bd30249c812f74ced5709b9 | |
parent | 101d925baaa9791fd3d70e6fe5368e984a36f0b7 (diff) | |
download | php-git-73e4913cca4561ec427d6f024210e307ba620d0e.tar.gz |
Fixed memory leaks
-rw-r--r-- | main/php_variables.c | 10 | ||||
-rw-r--r-- | sapi/cgi/cgi_main.c | 4 |
2 files changed, 8 insertions, 6 deletions
diff --git a/main/php_variables.c b/main/php_variables.c index 42d16bffb8..04fb6edb40 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -421,10 +421,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? */ @@ -470,15 +468,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 (PG(register_globals) || SG(request_info).argc) { arr->refcount++; @@ -492,6 +488,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); } /* }}} */ diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index a7460c8cc4..2aaae382f0 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -433,12 +433,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; } |