dmitry          Thu Nov 22 13:27:15 2007 UTC

  Added files:                 (Branch: PHP_5_3)
    /ZendEngine2/tests  bug43128.phpt 

  Modified files:              
    /php-src    NEWS 
    /TSRM       tsrm_config_common.h tsrm_virtual_cwd.c 
    /ZendEngine2        zend.h zend_API.c zend_builtin_functions.c 
                        zend_compile.c zend_compile.h zend_execute.c 
                        zend_execute_API.c zend_object_handlers.c 
                        zend_vm_execute.h zend_vm_execute.skl 
    /php-src/ext/interbase      ibase_query.c 
    /php-src/ext/reflection     php_reflection.c 
    /php-src/ext/spl    php_spl.c 
    /php-src/main       main.c 
  Log:
  Fixed bug #43128 (Very long class name causes segfault)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.965.2.52&r2=1.2027.2.547.2.965.2.53&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.965.2.52 
php-src/NEWS:1.2027.2.547.2.965.2.53
--- php-src/NEWS:1.2027.2.547.2.965.2.52        Wed Nov 21 05:44:34 2007
+++ php-src/NEWS        Thu Nov 22 13:27:10 2007
@@ -62,6 +62,7 @@
 - Fixed bug #43136 (possible crash on script execution timeout.
   The EG(function_state_ptr) is completely removed,
   EG(current_execute_data)->function_state must be used instead). (Dmitry)
+- Fixed bug #43128 (Very long class name causes segfault). (Dmitry)
 - Fixed bug #42848 (Status: header incorrect under FastCGI). (Dmitry)
 - Fixed bug #42773 (WSDL error causes HTTP 500 Response). (Dmitry)
 - Fixed bug #42737 (preg_split('//u') triggers a E_NOTICE with newlines). 
(Nuno)
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_config_common.h?r1=1.17.2.1.2.1&r2=1.17.2.1.2.1.2.1&diff_format=u
Index: TSRM/tsrm_config_common.h
diff -u TSRM/tsrm_config_common.h:1.17.2.1.2.1 
TSRM/tsrm_config_common.h:1.17.2.1.2.1.2.1
--- TSRM/tsrm_config_common.h:1.17.2.1.2.1      Thu Feb 15 19:11:48 2007
+++ TSRM/tsrm_config_common.h   Thu Nov 22 13:27:11 2007
@@ -52,9 +52,17 @@
 #endif
 
 #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2))
-# define tsrm_do_alloca(p) alloca(p)
-# define tsrm_free_alloca(p)
+# define TSRM_ALLOCA_MAX_SIZE 4096
+# define TSRM_ALLOCA_FLAG(name) \
+       int name;
+# define tsrm_do_alloca_ex(size, limit, use_heap) \
+       ((use_heap = ((size) > (limit))) ? malloc(size) : alloca(size))
+# define tsrm_do_alloca(size, use_heap) \
+       tsrm_do_alloca_ex(size, TSRM_ALLOCA_MAX_SIZE, use_heap)
+# define tsrm_free_alloca(p, use_heap) \
+       do { if (use_heap) free(p); } while (0)
 #else
+# define TSRM_ALLOCA_FLAG(name)
 # define tsrm_do_alloca(p)   malloc(p)
 # define tsrm_free_alloca(p) free(p)
 #endif
http://cvs.php.net/viewvc.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.74.2.9.2.35.2.2&r2=1.74.2.9.2.35.2.3&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.2 
TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.3
--- TSRM/tsrm_virtual_cwd.c:1.74.2.9.2.35.2.2   Tue Nov 13 09:47:06 2007
+++ TSRM/tsrm_virtual_cwd.c     Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.2 2007/11/13 09:47:06 dmitry Exp 
$ */
+/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9.2.35.2.3 2007/11/22 13:27:11 dmitry Exp 
$ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -777,6 +777,7 @@
        int length = strlen(path);
        char *temp;
        int retval;
+       TSRM_ALLOCA_FLAG(use_heap)
 
        if (length == 0) {
                return 1; /* Can't cd to empty string */
@@ -793,14 +794,14 @@
        if (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, 
length+1)) { /* Also use trailing slash if this is absolute */
                length++;
        }
-       temp = (char *) tsrm_do_alloca(length+1);
+       temp = (char *) tsrm_do_alloca(length+1, use_heap);
        memcpy(temp, path, length);
        temp[length] = 0;
 #if VIRTUAL_CWD_DEBUG
        fprintf (stderr, "Changing directory to %s\n", temp);
 #endif
        retval = p_chdir(temp TSRMLS_CC);
-       tsrm_free_alloca(temp);
+       tsrm_free_alloca(temp, use_heap);
        return retval;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.293.2.11.2.9.2.11&r2=1.293.2.11.2.9.2.12&diff_format=u
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.293.2.11.2.9.2.11 
ZendEngine2/zend.h:1.293.2.11.2.9.2.12
--- ZendEngine2/zend.h:1.293.2.11.2.9.2.11      Wed Nov 21 14:55:41 2007
+++ ZendEngine2/zend.h  Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.h,v 1.293.2.11.2.9.2.11 2007/11/21 14:55:41 dmitry Exp $ */
+/* $Id: zend.h,v 1.293.2.11.2.9.2.12 2007/11/22 13:27:11 dmitry Exp $ */
 
 #ifndef ZEND_H
 #define ZEND_H
@@ -177,9 +177,17 @@
 #endif
 
 #if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) 
&& defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && 
!(defined(ZTS) && defined(HPUX)) && !defined(DARWIN)
-# define do_alloca(p) alloca(p)
-# define free_alloca(p)
+# define ZEND_ALLOCA_MAX_SIZE (32 * 1024)
+# define ALLOCA_FLAG(name) \
+       zend_bool name;
+# define do_alloca_ex(size, limit, use_heap) \
+       ((use_heap = (UNEXPECTED((size) > (limit)))) ? emalloc(size) : 
alloca(size))
+# define do_alloca(size, use_heap) \
+       do_alloca_ex(size, ZEND_ALLOCA_MAX_SIZE, use_heap)
+# define free_alloca(p, use_heap) \
+       do { if (UNEXPECTED(use_heap)) efree(p); } while (0)
 #else
+# define ALLOCA_FLAG(name)
 # define do_alloca(p)          emalloc(p)
 # define free_alloca(p)        efree(p)
 #endif
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_API.c?r1=1.296.2.27.2.34.2.11&r2=1.296.2.27.2.34.2.12&diff_format=u
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.296.2.27.2.34.2.11 
ZendEngine2/zend_API.c:1.296.2.27.2.34.2.12
--- ZendEngine2/zend_API.c:1.296.2.27.2.34.2.11 Tue Nov 20 09:51:11 2007
+++ ZendEngine2/zend_API.c      Thu Nov 22 13:27:11 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_API.c,v 1.296.2.27.2.34.2.11 2007/11/20 09:51:11 dmitry Exp $ */
+/* $Id: zend_API.c,v 1.296.2.27.2.34.2.12 2007/11/22 13:27:11 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_execute.h"
@@ -1863,11 +1863,10 @@
                        }
                }
                fname_len = strlen(ptr->fname);
-               lowercase_name = do_alloca(fname_len+1);
-               zend_str_tolower_copy(lowercase_name, ptr->fname, fname_len);
+               lowercase_name = zend_str_tolower_dup(ptr->fname, fname_len);
                if (zend_hash_add(target_function_table, lowercase_name, 
fname_len+1, &function, sizeof(zend_function), (void**)&reg_function) == 
FAILURE) {
                        unload=1;
-                       free_alloca(lowercase_name);
+                       efree(lowercase_name);
                        break;
                }
                if (scope) {
@@ -1909,7 +1908,7 @@
                }
                ptr++;
                count++;
-               free_alloca(lowercase_name);
+               efree(lowercase_name);
        }
        if (unload) { /* before unloading, display all remaining bad function 
in the module */
                if (scope) {
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.277.2.12.2.25.2.5&r2=1.277.2.12.2.25.2.6&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.5 
ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.6
--- ZendEngine2/zend_builtin_functions.c:1.277.2.12.2.25.2.5    Sun Oct  7 
05:22:02 2007
+++ ZendEngine2/zend_builtin_functions.c        Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.5 2007/10/07 05:22:02 
davidw Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.277.2.12.2.25.2.6 2007/11/22 13:27:11 
dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -1034,19 +1034,20 @@
        char *class_name, *lc_name;
        zend_class_entry **ce;
        int class_name_len;
-       zend_bool autoload = 1;
        int found;
+       zend_bool autoload = 1;
+       ALLOCA_FLAG(use_heap)
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", 
&class_name, &class_name_len, &autoload) == FAILURE) {
                return;
        }
 
        if (!autoload) {
-               lc_name = do_alloca(class_name_len + 1);
+               lc_name = do_alloca(class_name_len + 1, use_heap);
                zend_str_tolower_copy(lc_name, class_name, class_name_len);
        
                found = zend_hash_find(EG(class_table), lc_name, 
class_name_len+1, (void **) &ce);
-               free_alloca(lc_name);
+               free_alloca(lc_name, use_heap);
                RETURN_BOOL(found == SUCCESS && !((*ce)->ce_flags & 
ZEND_ACC_INTERFACE));
        }
 
@@ -1065,19 +1066,20 @@
        char *iface_name, *lc_name;
        zend_class_entry **ce;
        int iface_name_len;
-       zend_bool autoload = 1;
        int found;
+       zend_bool autoload = 1;
+       ALLOCA_FLAG(use_heap)
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", 
&iface_name, &iface_name_len, &autoload) == FAILURE) {
                return;
        }
 
        if (!autoload) {
-               lc_name = do_alloca(iface_name_len + 1);
+               lc_name = do_alloca(iface_name_len + 1, use_heap);
                zend_str_tolower_copy(lc_name, iface_name, iface_name_len);
        
                found = zend_hash_find(EG(class_table), lc_name, 
iface_name_len+1, (void **) &ce);
-               free_alloca(lc_name);
+               free_alloca(lc_name, use_heap);
                RETURN_BOOL(found == SUCCESS && (*ce)->ce_flags & 
ZEND_ACC_INTERFACE);
        }
 
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.25&r2=1.647.2.27.2.41.2.26&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.25 
ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.26
--- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.25     Thu Nov 22 10:46:26 2007
+++ ZendEngine2/zend_compile.c  Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.25 2007/11/22 10:46:26 dmitry Exp $ 
*/
+/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.26 2007/11/22 13:27:11 dmitry Exp $ 
*/
 
 #include <zend_language_parser.h>
 #include "zend.h"
@@ -1088,6 +1088,7 @@
        zend_uint fn_flags;
        char *lcname;
        zend_bool orig_interactive;
+       ALLOCA_FLAG(use_heap)
 
        if (is_method) {
                if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
@@ -1148,7 +1149,7 @@
                }
 
                if (!(CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE)) {
-                       short_class_name = do_alloca(short_class_name_length + 
1);
+                       short_class_name = do_alloca(short_class_name_length + 
1, use_heap);
                        zend_str_tolower_copy(short_class_name, 
CG(active_class_entry)->name, short_class_name_length);
                        /* Improve after RC: cache the lowercase class name */
 
@@ -1184,7 +1185,7 @@
                        } else if (!(fn_flags & ZEND_ACC_STATIC)) {
                                CG(active_op_array)->fn_flags |= 
ZEND_ACC_ALLOW_STATIC;
                        }
-                       free_alloca(short_class_name);
+                       free_alloca(short_class_name, use_heap);
                }
 
                efree(lcname);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.316.2.8.2.12.2.9&r2=1.316.2.8.2.12.2.10&diff_format=u
Index: ZendEngine2/zend_compile.h
diff -u ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.9 
ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.10
--- ZendEngine2/zend_compile.h:1.316.2.8.2.12.2.9       Wed Nov 21 09:41:33 2007
+++ ZendEngine2/zend_compile.h  Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_compile.h,v 1.316.2.8.2.12.2.9 2007/11/21 09:41:33 johannes Exp $ 
*/
+/* $Id: zend_compile.h,v 1.316.2.8.2.12.2.10 2007/11/22 13:27:11 dmitry Exp $ 
*/
 
 #ifndef ZEND_COMPILE_H
 #define ZEND_COMPILE_H
@@ -299,6 +299,7 @@
        union _temp_variable *Ts;
        zval ***CVs;
        zend_bool original_in_execution;
+       ALLOCA_FLAG(use_heap)
        HashTable *symbol_table;
        struct _zend_execute_data *prev_execute_data;
        zval *old_error_reporting;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute.c?r1=1.716.2.12.2.24.2.7&r2=1.716.2.12.2.24.2.8&diff_format=u
Index: ZendEngine2/zend_execute.c
diff -u ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.7 
ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.8
--- ZendEngine2/zend_execute.c:1.716.2.12.2.24.2.7      Wed Nov 21 12:28:13 2007
+++ ZendEngine2/zend_execute.c  Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.7 2007/11/21 12:28:13 dmitry Exp $ 
*/
+/* $Id: zend_execute.c,v 1.716.2.12.2.24.2.8 2007/11/22 13:27:11 dmitry Exp $ 
*/
 
 #define ZEND_INTENSIVE_DEBUGGING 0
 
@@ -1427,12 +1427,7 @@
        }
 
 #define ZEND_VM_EXIT_FROM_EXECUTE_LOOP() \
-       free_alloca(EX(CVs)); \
-       if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \
-               free_alloca(EX(Ts)); \
-       } else { \
-               efree(EX(Ts)); \
-       } \
+       free_alloca(EX(CVs), EX(use_heap)); \
        EG(in_execution) = EX(original_in_execution); \
        EG(current_execute_data) = EX(prev_execute_data); \
        EG(opline_ptr) = NULL;
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_execute_API.c?r1=1.331.2.20.2.24.2.12&r2=1.331.2.20.2.24.2.13&diff_format=u
Index: ZendEngine2/zend_execute_API.c
diff -u ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.12 
ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.13
--- ZendEngine2/zend_execute_API.c:1.331.2.20.2.24.2.12 Wed Nov 21 09:41:33 2007
+++ ZendEngine2/zend_execute_API.c      Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.12 2007/11/21 09:41:33 johannes 
Exp $ */
+/* $Id: zend_execute_API.c,v 1.331.2.20.2.24.2.13 2007/11/22 13:27:11 dmitry 
Exp $ */
 
 #include <stdio.h>
 #include <signal.h>
@@ -1082,15 +1082,16 @@
        char *lc_name;
        char *lc_free;
        zval *exception;
-       char dummy = 1;
        zend_fcall_info fcall_info;
        zend_fcall_info_cache fcall_cache;
+       char dummy = 1;
+       ALLOCA_FLAG(use_heap)
 
        if (name == NULL || !name_length) {
                return FAILURE;
        }
 
-       lc_free = lc_name = do_alloca(name_length + 1);
+       lc_free = lc_name = do_alloca(name_length + 1, use_heap);
        zend_str_tolower_copy(lc_name, name, name_length);
 
        if (lc_name[0] == ':' && lc_name[1] == ':') {
@@ -1099,7 +1100,7 @@
        }
 
        if (zend_hash_find(EG(class_table), lc_name, name_length + 1, (void **) 
ce) == SUCCESS) {
-               free_alloca(lc_free);
+               free_alloca(lc_free, use_heap);
                return SUCCESS;
        }
 
@@ -1107,7 +1108,7 @@
         * (doesn't impact fuctionality of __autoload()
        */
        if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
-               free_alloca(lc_free);
+               free_alloca(lc_free, use_heap);
                return FAILURE;
        }
 
@@ -1117,7 +1118,7 @@
        }
 
        if (zend_hash_add(EG(in_autoload), lc_name, name_length + 1, 
(void**)&dummy, sizeof(char), NULL) == FAILURE) {
-               free_alloca(lc_free);
+               free_alloca(lc_free, use_heap);
                return FAILURE;
        }
 
@@ -1155,12 +1156,12 @@
 
        if (retval == FAILURE) {
                EG(exception) = exception;
-               free_alloca(lc_free);
+               free_alloca(lc_free, use_heap);
                return FAILURE;
        }
 
        if (EG(exception) && exception) {
-               free_alloca(lc_free);
+               free_alloca(lc_free, use_heap);
                zend_error(E_ERROR, "Function %s(%s) threw an exception of type 
'%s'", ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
                return FAILURE;
        }
@@ -1172,7 +1173,7 @@
        }
 
        retval = zend_hash_find(EG(class_table), lc_name, name_length + 1, 
(void **) ce);
-       free_alloca(lc_free);
+       free_alloca(lc_free, use_heap);
        return retval;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_object_handlers.c?r1=1.135.2.6.2.22.2.8&r2=1.135.2.6.2.22.2.9&diff_format=u
Index: ZendEngine2/zend_object_handlers.c
diff -u ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.8 
ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.9
--- ZendEngine2/zend_object_handlers.c:1.135.2.6.2.22.2.8       Tue Nov 20 
09:51:11 2007
+++ ZendEngine2/zend_object_handlers.c  Thu Nov 22 13:27:11 2007
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.8 2007/11/20 09:51:11 dmitry 
Exp $ */
+/* $Id: zend_object_handlers.c,v 1.135.2.6.2.22.2.9 2007/11/22 13:27:11 dmitry 
Exp $ */
 
 #include "zend.h"
 #include "zend_globals.h"
@@ -776,14 +776,15 @@
        zend_function *fbc;
        char *lc_method_name;
        zval *object = *object_ptr;
+       ALLOCA_FLAG(use_heap)
 
-       lc_method_name = do_alloca(method_len+1);
+       lc_method_name = do_alloca(method_len+1, use_heap);
        /* Create a zend_copy_str_tolower(dest, src, src_length); */
        zend_str_tolower_copy(lc_method_name, method_name, method_len);
 
        zobj = Z_OBJ_P(object);
        if (zend_hash_find(&zobj->ce->function_table, lc_method_name, 
method_len+1, (void **)&fbc) == FAILURE) {
-               free_alloca(lc_method_name);
+               free_alloca(lc_method_name, use_heap);
                if (zobj->ce->__call) {
                        zend_internal_function *call_user_call = 
emalloc(sizeof(zend_internal_function));
                        call_user_call->type = ZEND_INTERNAL_FUNCTION;
@@ -838,7 +839,7 @@
                }
        }
 
-       free_alloca(lc_method_name);
+       free_alloca(lc_method_name, use_heap);
        return fbc;
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.h?r1=1.62.2.30.2.49.2.22&r2=1.62.2.30.2.49.2.23&diff_format=u
Index: ZendEngine2/zend_vm_execute.h
diff -u ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.22 
ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.23
--- ZendEngine2/zend_vm_execute.h:1.62.2.30.2.49.2.22   Thu Nov 22 09:02:54 2007
+++ ZendEngine2/zend_vm_execute.h       Thu Nov 22 13:27:11 2007
@@ -45,12 +45,13 @@
        EX(called_scope) = NULL;
        EX(object) = NULL;
        EX(old_error_reporting) = NULL;
-       if (op_array->T < TEMP_VAR_STACK_LIMIT) {
-               EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * 
op_array->T);
+       if (EXPECTED(op_array->T < TEMP_VAR_STACK_LIMIT && op_array->last_var < 
TEMP_VAR_STACK_LIMIT)) {
+               EX(CVs) = (zval***)do_alloca(sizeof(zval**) * 
op_array->last_var + sizeof(temp_variable) * op_array->T, EX(use_heap));
        } else {
-               EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), 
op_array->T, 0);
+               EX(use_heap) = 1;
+               EX(CVs) = (zval***)safe_emalloc(sizeof(temp_variable), 
op_array->T, sizeof(zval**) * op_array->last_var);
        }
-       EX(CVs) = (zval***)do_alloca(sizeof(zval**) * op_array->last_var);
+       EX(Ts) = (temp_variable *)(EX(CVs) + op_array->last_var);
        memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var);
        EX(op_array) = op_array;
        EX(original_in_execution) = EG(in_execution);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_execute.skl?r1=1.2.2.2.2.1.2.3&r2=1.2.2.2.2.1.2.4&diff_format=u
Index: ZendEngine2/zend_vm_execute.skl
diff -u ZendEngine2/zend_vm_execute.skl:1.2.2.2.2.1.2.3 
ZendEngine2/zend_vm_execute.skl:1.2.2.2.2.1.2.4
--- ZendEngine2/zend_vm_execute.skl:1.2.2.2.2.1.2.3     Tue Nov 20 09:51:12 2007
+++ ZendEngine2/zend_vm_execute.skl     Thu Nov 22 13:27:12 2007
@@ -16,12 +16,13 @@
        EX(called_scope) = NULL;
        EX(object) = NULL;
        EX(old_error_reporting) = NULL;
-       if (op_array->T < TEMP_VAR_STACK_LIMIT) {
-               EX(Ts) = (temp_variable *) do_alloca(sizeof(temp_variable) * 
op_array->T);
+       if (EXPECTED(op_array->T < TEMP_VAR_STACK_LIMIT && op_array->last_var < 
TEMP_VAR_STACK_LIMIT)) {
+               EX(CVs) = (zval***)do_alloca(sizeof(zval**) * 
op_array->last_var + sizeof(temp_variable) * op_array->T, EX(use_heap));
        } else {
-               EX(Ts) = (temp_variable *) safe_emalloc(sizeof(temp_variable), 
op_array->T, 0);
+               EX(use_heap) = 1;
+               EX(CVs) = (zval***)safe_emalloc(sizeof(temp_variable), 
op_array->T, sizeof(zval**) * op_array->last_var);
        }
-       EX(CVs) = (zval***)do_alloca(sizeof(zval**) * op_array->last_var);
+       EX(Ts) = (temp_variable *)(EX(CVs) + op_array->last_var);
        memset(EX(CVs), 0, sizeof(zval**) * op_array->last_var);
        EX(op_array) = op_array;
        EX(original_in_execution) = EG(in_execution);
http://cvs.php.net/viewvc.cgi/php-src/ext/interbase/ibase_query.c?r1=1.23.2.1.2.10.2.3&r2=1.23.2.1.2.10.2.4&diff_format=u
Index: php-src/ext/interbase/ibase_query.c
diff -u php-src/ext/interbase/ibase_query.c:1.23.2.1.2.10.2.3 
php-src/ext/interbase/ibase_query.c:1.23.2.1.2.10.2.4
--- php-src/ext/interbase/ibase_query.c:1.23.2.1.2.10.2.3       Tue Nov 20 
21:36:20 2007
+++ php-src/ext/interbase/ibase_query.c Thu Nov 22 13:27:13 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: ibase_query.c,v 1.23.2.1.2.10.2.3 2007/11/20 21:36:20 lwe Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.10.2.4 2007/11/22 13:27:13 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1843,6 +1843,7 @@
        zval *query, ***args = NULL;
        ibase_query *ib_query;
        ibase_result *result = NULL;
+       ALLOCA_FLAG(use_heap)
 
        RESET_ERRMSG;
        
@@ -1866,7 +1867,7 @@
                        }
 
                } else if (bind_n > 0) { /* have variables to bind */
-                       args = (zval ***) do_alloca(ZEND_NUM_ARGS() * 
sizeof(zval **));
+                       args = (zval ***) do_alloca(ZEND_NUM_ARGS() * 
sizeof(zval **), use_heap);
        
                        if (FAILURE == 
zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) {
                                break;
@@ -1907,7 +1908,7 @@
        } while (0);
 
        if (args) {
-               free_alloca(args);
+               free_alloca(args, use_heap);
        }
 }
 /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.45.2.4&r2=1.164.2.33.2.45.2.5&diff_format=u
Index: php-src/ext/reflection/php_reflection.c
diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.4 
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.5
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.45.2.4 Sun Oct 28 
13:42:24 2007
+++ php-src/ext/reflection/php_reflection.c     Thu Nov 22 13:27:13 2007
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.4 2007/10/28 13:42:24 iliaa Exp $ 
*/
+/* $Id: php_reflection.c,v 1.164.2.33.2.45.2.5 2007/11/22 13:27:13 dmitry Exp 
$ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -1047,14 +1047,15 @@
        int name_len = strlen(name_str);
        char *lcname;
        struct _zend_module_entry *module;
+       ALLOCA_FLAG(use_heap)
 
-       lcname = do_alloca(name_len + 1);
+       lcname = do_alloca(name_len + 1, use_heap);
        zend_str_tolower_copy(lcname, name_str, name_len);
        if (zend_hash_find(&module_registry, lcname, name_len + 1, (void 
**)&module) == FAILURE) {
-               free_alloca(lcname);
+               free_alloca(lcname, use_heap);
                return;
        }
-       free_alloca(lcname);
+       free_alloca(lcname, use_heap);
 
        reflection_instantiate(reflection_extension_ptr, object TSRMLS_CC);
        intern = (reflection_object *) zend_object_store_get_object(object 
TSRMLS_CC);
@@ -4127,6 +4128,7 @@
        zend_module_entry *module;
        char *name_str;
        int name_len;
+       ALLOCA_FLAG(use_heap)
 
        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name_str, 
&name_len) == FAILURE) {
                return;
@@ -4137,15 +4139,15 @@
        if (intern == NULL) {
                return;
        }
-       lcname = do_alloca(name_len + 1);
+       lcname = do_alloca(name_len + 1, use_heap);
        zend_str_tolower_copy(lcname, name_str, name_len);
        if (zend_hash_find(&module_registry, lcname, name_len + 1, (void 
**)&module) == FAILURE) {
-               free_alloca(lcname);
+               free_alloca(lcname, use_heap);
                zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, 
                        "Extension %s does not exist", name_str);
                return;
        }
-       free_alloca(lcname);
+       free_alloca(lcname, use_heap);
        MAKE_STD_ZVAL(name);
        ZVAL_STRING(name, module->name, 1);
        zend_hash_update(Z_OBJPROP_P(object), "name", sizeof("name"), (void **) 
&name, sizeof(zval *), NULL);
@@ -4907,7 +4909,7 @@
        php_info_print_table_start();
        php_info_print_table_header(2, "Reflection", "enabled");
 
-       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 
1.164.2.33.2.45.2.4 2007/10/28 13:42:24 iliaa Exp $");
+       php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 
1.164.2.33.2.45.2.5 2007/11/22 13:27:13 dmitry Exp $");
 
        php_info_print_table_end();
 } /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/php_spl.c?r1=1.52.2.28.2.17.2.4&r2=1.52.2.28.2.17.2.5&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.4 
php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.5
--- php-src/ext/spl/php_spl.c:1.52.2.28.2.17.2.4        Tue Nov 20 09:51:12 2007
+++ php-src/ext/spl/php_spl.c   Thu Nov 22 13:27:13 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_spl.c,v 1.52.2.28.2.17.2.4 2007/11/20 09:51:12 dmitry Exp $ */
+/* $Id: php_spl.c,v 1.52.2.28.2.17.2.5 2007/11/22 13:27:13 dmitry Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -72,12 +72,13 @@
 
        if (!autoload) {
                char *lc_name;
+               ALLOCA_FLAG(use_heap)
 
-               lc_name = do_alloca(len + 1);
+               lc_name = do_alloca(len + 1, use_heap);
                zend_str_tolower_copy(lc_name, name, len);
 
                found = zend_hash_find(EG(class_table), lc_name, len +1, (void 
**) &ce);
-               free_alloca(lc_name);
+               free_alloca(lc_name, use_heap);
        } else {
                found = zend_lookup_class(name, len, &ce TSRMLS_CC);
        }
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.640.2.23.2.57.2.3&r2=1.640.2.23.2.57.2.4&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.640.2.23.2.57.2.3 
php-src/main/main.c:1.640.2.23.2.57.2.4
--- php-src/main/main.c:1.640.2.23.2.57.2.3     Thu Oct 18 13:11:46 2007
+++ php-src/main/main.c Thu Nov 22 13:27:13 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c,v 1.640.2.23.2.57.2.3 2007/10/18 13:11:46 dmitry Exp $ */
+/* $Id: main.c,v 1.640.2.23.2.57.2.4 2007/11/22 13:27:13 dmitry Exp $ */
 
 /* {{{ includes
  */
@@ -1929,6 +1929,7 @@
        int old_cwd_fd = -1;
 #else
        char *old_cwd;
+       ALLOCA_FLAG(use_heap)
 #endif
        int retval = 0;
 
@@ -1939,7 +1940,7 @@
        }
 #ifndef HAVE_BROKEN_GETCWD
 # define OLD_CWD_SIZE 4096
-       old_cwd = do_alloca(OLD_CWD_SIZE);
+       old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
        old_cwd[0] = '\0';
 #endif
 
@@ -2017,7 +2018,7 @@
        if (old_cwd[0] != '\0') {
                VCWD_CHDIR(old_cwd);
        }
-       free_alloca(old_cwd);
+       free_alloca(old_cwd, use_heap);
 #endif
        return retval;
 }
@@ -2028,10 +2029,11 @@
 PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval 
**ret TSRMLS_DC)
 {
        char *old_cwd;
+       ALLOCA_FLAG(use_heap)
 
        EG(exit_status) = 0;
 #define OLD_CWD_SIZE 4096
-       old_cwd = do_alloca(OLD_CWD_SIZE);
+       old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
        old_cwd[0] = '\0';
 
        zend_try {
@@ -2052,7 +2054,7 @@
                VCWD_CHDIR(old_cwd);
        }
 
-       free_alloca(old_cwd);
+       free_alloca(old_cwd, use_heap);
        return EG(exit_status);
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/bug43128.phpt?view=markup&rev=1.1
Index: ZendEngine2/tests/bug43128.phpt
+++ ZendEngine2/tests/bug43128.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to