dmitry Thu, 26 Aug 2010 12:20:35 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302796
Log:
Use stack instead of heap
Changed paths:
U php/php-src/trunk/main/php_variables.c
Modified: php/php-src/trunk/main/php_variables.c
===================================================================
--- php/php-src/trunk/main/php_variables.c 2010-08-26 09:04:37 UTC (rev
302795)
+++ php/php-src/trunk/main/php_variables.c 2010-08-26 12:20:35 UTC (rev
302796)
@@ -67,6 +67,7 @@
zval *gpc_element, **gpc_element_p;
zend_bool is_array = 0;
HashTable *symtable1 = NULL;
+ ALLOCA_FLAG(use_heap)
assert(var_name != NULL);
@@ -80,17 +81,19 @@
return;
}
+
+ /* ignore leading spaces in the variable name */
+ while (*var_name && *var_name==' ') {
+ var_name++;
+ }
+
/*
* Prepare variable name
*/
+ var_len = strlen(var_name);
+ var = var_orig = do_alloca(var_len + 1, use_heap);
+ memcpy(var_orig, var_name, var_len + 1);
- var_orig = estrdup(var_name);
- var = var_orig;
- /* ignore leading spaces in the variable name */
- while (*var && *var==' ') {
- var++;
- }
-
/* ensure that we don't have spaces or dots in the variable name (not
binary safe) */
for (p = var; *p; p++) {
if (*p == ' ' || *p == '.') {
@@ -106,7 +109,7 @@
if (var_len==0) { /* empty variable name, or variable name with a space
in it */
zval_dtor(val);
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -115,7 +118,7 @@
var_len == sizeof("GLOBALS")-1 &&
!memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) {
zval_dtor(val);
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -144,7 +147,7 @@
if (!PG(display_errors)) {
php_error_docref(NULL TSRMLS_CC,
E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit
change max_input_nesting_level in php.ini.", PG(max_input_nesting_level));
}
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
return;
}
@@ -236,7 +239,7 @@
}
}
}
- efree(var_orig);
+ free_alloca(var_orig, use_heap);
}
SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php