summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_alloc.c2
-rw-r--r--Zend/zend_hash.c28
-rw-r--r--Zend/zend_variables.c8
-rw-r--r--ext/mssql/php_mssql.c1
-rw-r--r--ext/session/session.c7
-rw-r--r--ext/sybase/php_sybase_db.c2
-rw-r--r--ext/sybase_ct/php_sybase_ct.c2
-rw-r--r--ext/w32api/w32api.c25
-rw-r--r--main/php_variables.c9
-rw-r--r--main/rfc1867.c7
-rw-r--r--sapi/apache/mod_php5.c15
-rw-r--r--sapi/apache_hooks/mod_php5.c15
12 files changed, 75 insertions, 46 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 0fabed4dd2..ff80a702b1 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -75,7 +75,7 @@ static long mem_block_end_magic = MEM_BLOCK_END_MAGIC;
#define _CHECK_MEMORY_LIMIT(s, rs, file, lineno) { AG(allocated_memory) += rs;\
if (AG(memory_limit)<AG(allocated_memory)) {\
int php_mem_limit = AG(memory_limit); \
- if (AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
+ if (EG(in_execution) && AG(memory_limit)+1048576 > AG(allocated_memory) - rs) { \
AG(memory_limit) = AG(allocated_memory) + 1048576; \
if (file) { \
zend_error(E_ERROR,"Allowed memory size of %d bytes exhausted at %s:%d (tried to allocate %d bytes)", php_mem_limit, file, lineno, s); \
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index fd518db340..065c9b4680 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -137,6 +137,7 @@ ZEND_API ulong zend_hash_func(char *arKey, uint nKeyLength)
ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC)
{
uint i = 3;
+ Bucket **tmp;
SET_INCONSISTENT(HT_OK);
@@ -146,18 +147,8 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio
ht->nTableSize = 1 << i;
ht->nTableMask = ht->nTableSize - 1;
-
- /* Uses ecalloc() so that Bucket* == NULL */
- if (persistent) {
- ht->arBuckets = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
- if (!ht->arBuckets) {
- return FAILURE;
- }
- } else {
- ht->arBuckets = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
- }
-
ht->pDestructor = pDestructor;
+ ht->arBuckets = NULL;
ht->pListHead = NULL;
ht->pListTail = NULL;
ht->nNumOfElements = 0;
@@ -166,6 +157,21 @@ ZEND_API int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunctio
ht->persistent = persistent;
ht->nApplyCount = 0;
ht->bApplyProtection = 1;
+
+ /* Uses ecalloc() so that Bucket* == NULL */
+ if (persistent) {
+ tmp = (Bucket **) calloc(ht->nTableSize, sizeof(Bucket *));
+ if (!tmp) {
+ return FAILURE;
+ }
+ ht->arBuckets = tmp;
+ } else {
+ tmp = (Bucket **) ecalloc_rel(ht->nTableSize, sizeof(Bucket *));
+ if (tmp) {
+ ht->arBuckets = tmp;
+ }
+ }
+
return SUCCESS;
}
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 51f51f8d8c..e6fbd5342c 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -140,14 +140,16 @@ ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
case IS_CONSTANT_ARRAY: {
zval *tmp;
HashTable *original_ht = zvalue->value.ht;
+ HashTable *tmp_ht = NULL;
TSRMLS_FETCH();
if (zvalue->value.ht == &EG(symbol_table)) {
return SUCCESS; /* do nothing */
}
- ALLOC_HASHTABLE_REL(zvalue->value.ht);
- zend_hash_init(zvalue->value.ht, 0, NULL, ZVAL_PTR_DTOR, 0);
- zend_hash_copy(zvalue->value.ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ ALLOC_HASHTABLE_REL(tmp_ht);
+ zend_hash_init(tmp_ht, 0, NULL, ZVAL_PTR_DTOR, 0);
+ zend_hash_copy(tmp_ht, original_ht, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));
+ zvalue->value.ht = tmp_ht;
}
break;
case IS_OBJECT:
diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c
index e99026b1d7..9930d3d0e4 100644
--- a/ext/mssql/php_mssql.c
+++ b/ext/mssql/php_mssql.c
@@ -348,6 +348,7 @@ PHP_RINIT_FUNCTION(mssql)
PHP_RSHUTDOWN_FUNCTION(mssql)
{
STR_FREE(MS_SQL_G(appname));
+ MS_SQL_G(appname) = NULL;
if (MS_SQL_G(server_message)) {
STR_FREE(MS_SQL_G(server_message));
MS_SQL_G(server_message) = NULL;
diff --git a/ext/session/session.c b/ext/session/session.c
index 71dc86f183..135a732253 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -518,13 +518,16 @@ break_outer_loop:
static void php_session_track_init(TSRMLS_D)
{
+ zval *session_vars = NULL;
+
/* Unconditionally destroy existing arrays -- possible dirty data */
zend_hash_del(&EG(symbol_table), "HTTP_SESSION_VARS",
sizeof("HTTP_SESSION_VARS"));
zend_hash_del(&EG(symbol_table), "_SESSION", sizeof("_SESSION"));
- MAKE_STD_ZVAL(PS(http_session_vars));
- array_init(PS(http_session_vars));
+ MAKE_STD_ZVAL(session_vars);
+ array_init(session_vars);
+ PS(http_session_vars) = session_vars;
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 2, 1);
ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 1);
diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c
index 2cd9032750..f2c98c7640 100644
--- a/ext/sybase/php_sybase_db.c
+++ b/ext/sybase/php_sybase_db.c
@@ -297,7 +297,9 @@ PHP_MSHUTDOWN_FUNCTION(sybase)
PHP_RSHUTDOWN_FUNCTION(sybase)
{
efree(php_sybase_module.appname);
+ php_sybase_module.appname = NULL;
STR_FREE(php_sybase_module.server_message);
+ php_sybase_module.server_message = NULL;
return SUCCESS;
}
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index 3d41d8b0af..43dca5df2a 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.c
@@ -448,11 +448,13 @@ PHP_MSHUTDOWN_FUNCTION(sybase)
PHP_RSHUTDOWN_FUNCTION(sybase)
{
efree(SybCtG(appname));
+ SybCtG(appname) = NULL;
if (SybCtG(callback_name)) {
zval_ptr_dtor(&SybCtG(callback_name));
SybCtG(callback_name)= NULL;
}
STR_FREE(SybCtG(server_message));
+ SybCtG(server_message) = NULL;
return SUCCESS;
}
diff --git a/ext/w32api/w32api.c b/ext/w32api/w32api.c
index 4dc52a86f5..b05b5449b7 100644
--- a/ext/w32api/w32api.c
+++ b/ext/w32api/w32api.c
@@ -287,20 +287,26 @@ PHP_MSHUTDOWN_FUNCTION(w32api)
*/
PHP_RINIT_FUNCTION(w32api)
{
+ HashTable *tmp;
+ WG(funcs) = WG(libraries) = WG(callbacks) = WG(types) = NULL;
+
/* Allocate Request Specific HT's here
*/
- ALLOC_HASHTABLE(WG(funcs));
- zend_hash_init(WG(funcs), 1, NULL, php_w32api_hash_func_dtor, 1);
-
- ALLOC_HASHTABLE(WG(libraries));
- zend_hash_init(WG(libraries), 1, NULL, php_w32api_hash_lib_dtor, 1);
+ ALLOC_HASHTABLE(tmp);
+ zend_hash_init(tmp, 1, NULL, php_w32api_hash_func_dtor, 1);
+ WG(funcs) = tmp;
- ALLOC_HASHTABLE(WG(callbacks));
- zend_hash_init(WG(callbacks), 1, NULL, php_w32api_hash_callback_dtor, 1);
+ ALLOC_HASHTABLE(tmp);
+ zend_hash_init(tmp, 1, NULL, php_w32api_hash_lib_dtor, 1);
+ WG(libraries) = tmp;
- ALLOC_HASHTABLE(WG(types));
- zend_hash_init(WG(types), 1, NULL, php_w32api_hash_type_dtor, 1);
+ ALLOC_HASHTABLE(tmp);
+ zend_hash_init(tmp, 1, NULL, php_w32api_hash_callback_dtor, 1);
+ WG(callbacks) = tmp;
+ ALLOC_HASHTABLE(tmp);
+ zend_hash_init(tmp, 1, NULL, php_w32api_hash_type_dtor, 1);
+ WG(types) = tmp;
return SUCCESS;
@@ -327,6 +333,7 @@ PHP_RSHUTDOWN_FUNCTION(w32api)
zend_hash_destroy(WG(types));
FREE_HASHTABLE(WG(types));
+ WG(funcs) = WG(libraries) = WG(callbacks) = WG(types) = NULL;
return SUCCESS;
}
diff --git a/main/php_variables.c b/main/php_variables.c
index 556a323219..8058fd634d 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -694,9 +694,12 @@ static zend_bool php_auto_globals_create_server(char *name, uint name_len TSRMLS
static zend_bool php_auto_globals_create_env(char *name, uint name_len TSRMLS_DC)
{
- ALLOC_ZVAL(PG(http_globals)[TRACK_VARS_ENV]);
- array_init(PG(http_globals)[TRACK_VARS_ENV]);
- INIT_PZVAL(PG(http_globals)[TRACK_VARS_ENV]);
+ zval *env_vars=NULL;
+ ALLOC_ZVAL(env_vars);
+ array_init(env_vars);
+ INIT_PZVAL(env_vars);
+ PG(http_globals)[TRACK_VARS_ENV] = env_vars;
+
php_import_environment_variables(PG(http_globals)[TRACK_VARS_ENV] TSRMLS_CC);
zend_hash_update(&EG(symbol_table), name, name_len+1, &PG(http_globals)[TRACK_VARS_ENV], sizeof(zval *), NULL);
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 4ba7298e93..c810688434 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -765,7 +765,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
char *temp_filename=NULL, *lbuf=NULL, *abuf=NULL;
int boundary_len=0, total_bytes=0, cancel_upload=0, is_arr_upload=0, array_len=0;
int max_file_size=0, skip_upload=0, anonindex=0, is_anonymous;
- zval *http_post_files=NULL;
+ zval *http_post_files=NULL; HashTable *uploaded_files=NULL;
#if HAVE_MBSTRING && !defined(COMPILE_DL_MBSTRING)
int str_len = 0, num_vars = 0, num_vars_max = 2*10, *len_list = NULL;
char **val_list = NULL;
@@ -816,8 +816,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler)
/* Initialize $_FILES[] */
zend_hash_init(&PG(rfc1867_protected_variables), 5, NULL, NULL, 0);
- ALLOC_HASHTABLE(SG(rfc1867_uploaded_files));
- zend_hash_init(SG(rfc1867_uploaded_files), 5, NULL, (dtor_func_t) free_estring, 0);
+ ALLOC_HASHTABLE(uploaded_files);
+ zend_hash_init(uploaded_files, 5, NULL, (dtor_func_t) free_estring, 0);
+ SG(rfc1867_uploaded_files) = uploaded_files;
ALLOC_ZVAL(http_post_files);
array_init(http_post_files);
diff --git a/sapi/apache/mod_php5.c b/sapi/apache/mod_php5.c
index 408ad2ed2e..d477a141a7 100644
--- a/sapi/apache/mod_php5.c
+++ b/sapi/apache/mod_php5.c
@@ -466,7 +466,7 @@ static void init_request_info(TSRMLS_D)
request_rec *r = ((request_rec *) SG(server_context));
char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
const char *authorization=NULL;
- char *tmp;
+ char *tmp, *tmp_user;
SG(request_info).query_string = r->args;
SG(request_info).path_translated = r->filename;
@@ -483,15 +483,16 @@ static void init_request_info(TSRMLS_D)
&& (!PG(safe_mode) || (PG(safe_mode) && !auth_type(r)))
&& !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
tmp = uudecode(r->pool, authorization);
- SG(request_info).auth_user = getword_nulls_nc(r->pool, &tmp, ':');
+ SG(request_info).auth_user = NULL;
+ tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
if (SG(request_info).auth_user) {
- r->connection->user = pstrdup(r->connection->pool, SG(request_info).auth_user);
+ r->connection->user = pstrdup(r->connection->pool, tmp_user);
r->connection->ap_auth_type = "Basic";
- SG(request_info).auth_user = estrdup(SG(request_info).auth_user);
+ SG(request_info).auth_user = estrdup(tmp_user);
}
- SG(request_info).auth_password = tmp;
- if (SG(request_info).auth_password) {
- SG(request_info).auth_password = estrdup(SG(request_info).auth_password);
+ SG(request_info).auth_password = NULL;
+ if (tmp) {
+ SG(request_info).auth_password = estrdup(tmp);
}
} else {
SG(request_info).auth_user = NULL;
diff --git a/sapi/apache_hooks/mod_php5.c b/sapi/apache_hooks/mod_php5.c
index b15f360475..547aed7400 100644
--- a/sapi/apache_hooks/mod_php5.c
+++ b/sapi/apache_hooks/mod_php5.c
@@ -564,7 +564,7 @@ static void init_request_info(TSRMLS_D)
request_rec *r = ((request_rec *) SG(server_context));
char *content_length = (char *) table_get(r->subprocess_env, "CONTENT_LENGTH");
const char *authorization=NULL;
- char *tmp;
+ char *tmp, *tmp_user;
SG(request_info).query_string = r->args;
SG(request_info).path_translated = r->filename;
@@ -581,15 +581,16 @@ static void init_request_info(TSRMLS_D)
&& !auth_type(r)
&& !strcasecmp(getword(r->pool, &authorization, ' '), "Basic")) {
tmp = uudecode(r->pool, authorization);
- SG(request_info).auth_user = getword_nulls_nc(r->pool, &tmp, ':');
+ SG(request_info).auth_user = NULL;
+ tmp_user = getword_nulls_nc(r->pool, &tmp, ':');
if (SG(request_info).auth_user) {
- r->connection->user = pstrdup(r->connection->pool, SG(request_info).auth_user);
+ r->connection->user = pstrdup(r->connection->pool, tmp_user);
r->connection->ap_auth_type = "Basic";
- SG(request_info).auth_user = estrdup(SG(request_info).auth_user);
+ SG(request_info).auth_user = estrdup(tmp_user);
}
- SG(request_info).auth_password = tmp;
- if (SG(request_info).auth_password) {
- SG(request_info).auth_password = estrdup(SG(request_info).auth_password);
+ SG(request_info).auth_password = NULL;
+ if (tmp) {
+ SG(request_info).auth_password = estrdup(tmp);
}
} else {
SG(request_info).auth_user = NULL;