PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_execute_API.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 0 736 0.0 %
Date: 2014-04-16 Functions: 0 44 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #include <stdio.h>
      23             : #include <signal.h>
      24             : 
      25             : #include "zend.h"
      26             : #include "zend_compile.h"
      27             : #include "zend_execute.h"
      28             : #include "zend_API.h"
      29             : #include "zend_ptr_stack.h"
      30             : #include "zend_constants.h"
      31             : #include "zend_extensions.h"
      32             : #include "zend_exceptions.h"
      33             : #include "zend_closures.h"
      34             : #include "zend_generators.h"
      35             : #include "zend_vm.h"
      36             : #include "zend_float.h"
      37             : #ifdef HAVE_SYS_TIME_H
      38             : #include <sys/time.h>
      39             : #endif
      40             : 
      41             : ZEND_API void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC);
      42             : ZEND_API void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, zend_fcall_info *fci, int return_value_used TSRMLS_DC);
      43             : 
      44             : /* true globals */
      45             : ZEND_API const zend_fcall_info empty_fcall_info = { 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 };
      46             : ZEND_API const zend_fcall_info_cache empty_fcall_info_cache = { 0, NULL, NULL, NULL, NULL };
      47             : 
      48             : #ifdef ZEND_WIN32
      49             : #include <process.h>
      50             : static WNDCLASS wc;
      51             : static HWND timeout_window;
      52             : static HANDLE timeout_thread_event;
      53             : static HANDLE timeout_thread_handle;
      54             : static DWORD timeout_thread_id;
      55             : static int timeout_thread_initialized=0;
      56             : #endif
      57             : 
      58             : #if 0&&ZEND_DEBUG
      59             : static void (*original_sigsegv_handler)(int);
      60             : static void zend_handle_sigsegv(int dummy) /* {{{ */
      61             : {
      62             :         fflush(stdout);
      63             :         fflush(stderr);
      64             :         if (original_sigsegv_handler == zend_handle_sigsegv) {
      65             :                 signal(SIGSEGV, original_sigsegv_handler);
      66             :         } else {
      67             :                 signal(SIGSEGV, SIG_DFL);
      68             :         }
      69             :         {
      70             :                 TSRMLS_FETCH();
      71             : 
      72             :                 fprintf(stderr, "SIGSEGV caught on opcode %d on opline %d of %s() at %s:%d\n\n",
      73             :                                 active_opline->opcode,
      74             :                                 active_opline-EG(active_op_array)->opcodes,
      75             :                                 get_active_function_name(TSRMLS_C),
      76             :                                 zend_get_executed_filename(TSRMLS_C),
      77             :                                 zend_get_executed_lineno(TSRMLS_C));
      78             : /* See http://support.microsoft.com/kb/190351 */
      79             : #ifdef PHP_WIN32
      80             :                 fflush(stderr);
      81             : #endif
      82             :         }
      83             :         if (original_sigsegv_handler!=zend_handle_sigsegv) {
      84             :                 original_sigsegv_handler(dummy);
      85             :         }
      86             : }
      87             : /* }}} */
      88             : #endif
      89             : 
      90           0 : static void zend_extension_activator(zend_extension *extension TSRMLS_DC) /* {{{ */
      91             : {
      92           0 :         if (extension->activate) {
      93           0 :                 extension->activate();
      94             :         }
      95           0 : }
      96             : /* }}} */
      97             : 
      98           0 : static void zend_extension_deactivator(zend_extension *extension TSRMLS_DC) /* {{{ */
      99             : {
     100           0 :         if (extension->deactivate) {
     101           0 :                 extension->deactivate();
     102             :         }
     103           0 : }
     104             : /* }}} */
     105             : 
     106           0 : static int clean_non_persistent_function(zend_function *function TSRMLS_DC) /* {{{ */
     107             : {
     108           0 :         return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
     109             : }
     110             : /* }}} */
     111             : 
     112           0 : static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC) /* {{{ */
     113             : {
     114           0 :         return (function->type == ZEND_INTERNAL_FUNCTION) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
     115             : }
     116             : /* }}} */
     117             : 
     118           0 : static int clean_non_persistent_class(zend_class_entry **ce TSRMLS_DC) /* {{{ */
     119             : {
     120           0 :         return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_STOP : ZEND_HASH_APPLY_REMOVE;
     121             : }
     122             : /* }}} */
     123             : 
     124           0 : static int clean_non_persistent_class_full(zend_class_entry **ce TSRMLS_DC) /* {{{ */
     125             : {
     126           0 :         return ((*ce)->type == ZEND_INTERNAL_CLASS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
     127             : }
     128             : /* }}} */
     129             : 
     130           0 : void init_executor(TSRMLS_D) /* {{{ */
     131             : {
     132           0 :         zend_init_fpu(TSRMLS_C);
     133             : 
     134           0 :         INIT_ZVAL(EG(uninitialized_zval));
     135             :         /* trick to make uninitialized_zval never be modified, passed by ref, etc. */
     136             :         Z_ADDREF(EG(uninitialized_zval));
     137           0 :         INIT_ZVAL(EG(error_zval));
     138           0 :         EG(uninitialized_zval_ptr)=&EG(uninitialized_zval);
     139           0 :         EG(error_zval_ptr)=&EG(error_zval);
     140             : /* destroys stack frame, therefore makes core dumps worthless */
     141             : #if 0&&ZEND_DEBUG
     142             :         original_sigsegv_handler = signal(SIGSEGV, zend_handle_sigsegv);
     143             : #endif
     144           0 :         EG(return_value_ptr_ptr) = NULL;
     145             : 
     146           0 :         EG(symtable_cache_ptr) = EG(symtable_cache) - 1;
     147           0 :         EG(symtable_cache_limit) = EG(symtable_cache) + SYMTABLE_CACHE_SIZE - 1;
     148           0 :         EG(no_extensions) = 0;
     149             : 
     150           0 :         EG(function_table) = CG(function_table);
     151           0 :         EG(class_table) = CG(class_table);
     152             : 
     153           0 :         EG(in_execution) = 0;
     154           0 :         EG(in_autoload) = NULL;
     155           0 :         EG(autoload_func) = NULL;
     156           0 :         EG(error_handling) = EH_NORMAL;
     157             : 
     158             :         zend_vm_stack_init(TSRMLS_C);
     159             :         zend_vm_stack_push((void *) NULL TSRMLS_CC);
     160             : 
     161           0 :         zend_hash_init(&EG(symbol_table), 50, NULL, ZVAL_PTR_DTOR, 0);
     162           0 :         EG(active_symbol_table) = &EG(symbol_table);
     163             : 
     164           0 :         zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_activator TSRMLS_CC);
     165           0 :         EG(opline_ptr) = NULL;
     166             : 
     167           0 :         zend_hash_init(&EG(included_files), 5, NULL, NULL, 0);
     168             : 
     169           0 :         EG(ticks_count) = 0;
     170             : 
     171           0 :         EG(user_error_handler) = NULL;
     172             : 
     173           0 :         EG(current_execute_data) = NULL;
     174             : 
     175           0 :         zend_stack_init(&EG(user_error_handlers_error_reporting));
     176           0 :         zend_ptr_stack_init(&EG(user_error_handlers));
     177           0 :         zend_ptr_stack_init(&EG(user_exception_handlers));
     178             : 
     179           0 :         zend_objects_store_init(&EG(objects_store), 1024);
     180             : 
     181           0 :         EG(full_tables_cleanup) = 0;
     182             : #ifdef ZEND_WIN32
     183             :         EG(timed_out) = 0;
     184             : #endif
     185             : 
     186           0 :         EG(exception) = NULL;
     187           0 :         EG(prev_exception) = NULL;
     188             : 
     189           0 :         EG(scope) = NULL;
     190           0 :         EG(called_scope) = NULL;
     191             : 
     192           0 :         EG(This) = NULL;
     193             : 
     194           0 :         EG(active_op_array) = NULL;
     195             : 
     196           0 :         EG(active) = 1;
     197           0 :         EG(start_op) = NULL;
     198           0 : }
     199             : /* }}} */
     200             : 
     201           0 : static int zval_call_destructor(zval **zv TSRMLS_DC) /* {{{ */
     202             : {
     203           0 :         if (Z_TYPE_PP(zv) == IS_OBJECT && Z_REFCOUNT_PP(zv) == 1) {
     204           0 :                 return ZEND_HASH_APPLY_REMOVE;
     205             :         } else {
     206           0 :                 return ZEND_HASH_APPLY_KEEP;
     207             :         }
     208             : }
     209             : /* }}} */
     210             : 
     211           0 : void shutdown_destructors(TSRMLS_D) /* {{{ */
     212             : {
     213           0 :         zend_try {
     214             :                 int symbols;
     215             :                 do {
     216           0 :                         symbols = zend_hash_num_elements(&EG(symbol_table));
     217           0 :                         zend_hash_reverse_apply(&EG(symbol_table), (apply_func_t) zval_call_destructor TSRMLS_CC);
     218           0 :                 } while (symbols != zend_hash_num_elements(&EG(symbol_table)));
     219           0 :                 zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC);
     220           0 :         } zend_catch {
     221             :                 /* if we couldn't destruct cleanly, mark all objects as destructed anyway */
     222           0 :                 zend_objects_store_mark_destructed(&EG(objects_store) TSRMLS_CC);
     223           0 :         } zend_end_try();
     224           0 : }
     225             : /* }}} */
     226             : 
     227           0 : void shutdown_executor(TSRMLS_D) /* {{{ */
     228             : {
     229           0 :         zend_try {
     230             : 
     231             : /* Removed because this can not be safely done, e.g. in this situation:
     232             :    Object 1 creates object 2
     233             :    Object 3 holds reference to object 2.
     234             :    Now when 1 and 2 are destroyed, 3 can still access 2 in its destructor, with
     235             :    very problematic results */
     236             : /*              zend_objects_store_call_destructors(&EG(objects_store) TSRMLS_CC); */
     237             : 
     238             : /* Moved after symbol table cleaners, because  some of the cleaners can call
     239             :    destructors, which would use EG(symtable_cache_ptr) and thus leave leaks */
     240             : /*              while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
     241             :                         zend_hash_destroy(*EG(symtable_cache_ptr));
     242             :                         efree(*EG(symtable_cache_ptr));
     243             :                         EG(symtable_cache_ptr)--;
     244             :                 }
     245             : */
     246           0 :                 zend_llist_apply(&zend_extensions, (llist_apply_func_t) zend_extension_deactivator TSRMLS_CC);
     247           0 :                 zend_hash_graceful_reverse_destroy(&EG(symbol_table));
     248           0 :         } zend_end_try();
     249             : 
     250           0 :         zend_try {
     251             :                 zval *zeh;
     252             :                 /* remove error handlers before destroying classes and functions,
     253             :                  * so that if handler used some class, crash would not happen */
     254           0 :                 if (EG(user_error_handler)) {
     255           0 :                         zeh = EG(user_error_handler);
     256           0 :                         EG(user_error_handler) = NULL;
     257           0 :                         zval_ptr_dtor(&zeh);
     258             :                 }
     259             : 
     260           0 :                 if (EG(user_exception_handler)) {
     261           0 :                         zeh = EG(user_exception_handler);
     262           0 :                         EG(user_exception_handler) = NULL;
     263           0 :                         zval_ptr_dtor(&zeh);
     264             :                 }
     265             : 
     266           0 :                 zend_stack_destroy(&EG(user_error_handlers_error_reporting));
     267           0 :                 zend_stack_init(&EG(user_error_handlers_error_reporting));
     268           0 :                 zend_ptr_stack_clean(&EG(user_error_handlers), ZVAL_DESTRUCTOR, 1);
     269           0 :                 zend_ptr_stack_clean(&EG(user_exception_handlers), ZVAL_DESTRUCTOR, 1);
     270           0 :         } zend_end_try();
     271             : 
     272           0 :         zend_try {
     273             :                 /* Cleanup static data for functions and arrays.
     274             :                  * We need a separate cleanup stage because of the following problem:
     275             :                  * Suppose we destroy class X, which destroys the class's function table,
     276             :                  * and in the function table we have function foo() that has static $bar.
     277             :                  * Now if an object of class X is assigned to $bar, its destructor will be
     278             :                  * called and will fail since X's function table is in mid-destruction.
     279             :                  * So we want first of all to clean up all data and then move to tables destruction.
     280             :                  * Note that only run-time accessed data need to be cleaned up, pre-defined data can
     281             :                  * not contain objects and thus are not probelmatic */
     282           0 :                 if (EG(full_tables_cleanup)) {
     283           0 :                         zend_hash_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data_full TSRMLS_CC);
     284           0 :                         zend_hash_apply(EG(class_table), (apply_func_t) zend_cleanup_class_data TSRMLS_CC);
     285             :                 } else {
     286           0 :                         zend_hash_reverse_apply(EG(function_table), (apply_func_t) zend_cleanup_function_data TSRMLS_CC);
     287           0 :                         zend_hash_reverse_apply(EG(class_table), (apply_func_t) zend_cleanup_user_class_data TSRMLS_CC);
     288           0 :                         zend_cleanup_internal_classes(TSRMLS_C);
     289             :                 }
     290           0 :         } zend_end_try();
     291             : 
     292           0 :         zend_try {
     293           0 :                 zend_objects_store_free_object_storage(&EG(objects_store) TSRMLS_CC);
     294             : 
     295             :                 zend_vm_stack_destroy(TSRMLS_C);
     296             : 
     297             :                 /* Destroy all op arrays */
     298           0 :                 if (EG(full_tables_cleanup)) {
     299           0 :                         zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function_full TSRMLS_CC);
     300           0 :                         zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class_full TSRMLS_CC);
     301             :                 } else {
     302           0 :                         zend_hash_reverse_apply(EG(function_table), (apply_func_t) clean_non_persistent_function TSRMLS_CC);
     303           0 :                         zend_hash_reverse_apply(EG(class_table), (apply_func_t) clean_non_persistent_class TSRMLS_CC);
     304             :                 }
     305             : 
     306           0 :                 while (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
     307           0 :                         zend_hash_destroy(*EG(symtable_cache_ptr));
     308           0 :                         FREE_HASHTABLE(*EG(symtable_cache_ptr));
     309           0 :                         EG(symtable_cache_ptr)--;
     310             :                 }
     311           0 :         } zend_end_try();
     312             : 
     313           0 :         zend_try {
     314           0 :                 clean_non_persistent_constants(TSRMLS_C);
     315           0 :         } zend_end_try();
     316             : 
     317           0 :         zend_try {
     318             : #if 0&&ZEND_DEBUG
     319             :         signal(SIGSEGV, original_sigsegv_handler);
     320             : #endif
     321             : 
     322           0 :                 zend_hash_destroy(&EG(included_files));
     323             : 
     324           0 :                 zend_stack_destroy(&EG(user_error_handlers_error_reporting));
     325           0 :                 zend_ptr_stack_destroy(&EG(user_error_handlers));
     326           0 :                 zend_ptr_stack_destroy(&EG(user_exception_handlers));
     327           0 :                 zend_objects_store_destroy(&EG(objects_store));
     328           0 :                 if (EG(in_autoload)) {
     329           0 :                         zend_hash_destroy(EG(in_autoload));
     330           0 :                         FREE_HASHTABLE(EG(in_autoload));
     331             :                 }
     332           0 :         } zend_end_try();
     333             : 
     334           0 :         zend_shutdown_fpu(TSRMLS_C);
     335             : 
     336           0 :         EG(active) = 0;
     337           0 : }
     338             : /* }}} */
     339             : 
     340             : /* return class name and "::" or "". */
     341           0 : ZEND_API const char *get_active_class_name(const char **space TSRMLS_DC) /* {{{ */
     342             : {
     343           0 :         if (!zend_is_executing(TSRMLS_C)) {
     344           0 :                 if (space) {
     345           0 :                         *space = "";
     346             :                 }
     347           0 :                 return "";
     348             :         }
     349           0 :         switch (EG(current_execute_data)->function_state.function->type) {
     350             :                 case ZEND_USER_FUNCTION:
     351             :                 case ZEND_INTERNAL_FUNCTION:
     352             :                 {
     353           0 :                         zend_class_entry *ce = EG(current_execute_data)->function_state.function->common.scope;
     354             : 
     355           0 :                         if (space) {
     356           0 :                                 *space = ce ? "::" : "";
     357             :                         }
     358           0 :                         return ce ? ce->name : "";
     359             :                 }
     360             :                 default:
     361           0 :                         if (space) {
     362           0 :                                 *space = "";
     363             :                         }
     364           0 :                         return "";
     365             :         }
     366             : }
     367             : /* }}} */
     368             : 
     369           0 : ZEND_API const char *get_active_function_name(TSRMLS_D) /* {{{ */
     370             : {
     371           0 :         if (!zend_is_executing(TSRMLS_C)) {
     372           0 :                 return NULL;
     373             :         }
     374           0 :         switch (EG(current_execute_data)->function_state.function->type) {
     375             :                 case ZEND_USER_FUNCTION: {
     376           0 :                                 const char *function_name = ((zend_op_array *) EG(current_execute_data)->function_state.function)->function_name;
     377             : 
     378           0 :                                 if (function_name) {
     379           0 :                                         return function_name;
     380             :                                 } else {
     381           0 :                                         return "main";
     382             :                                 }
     383             :                         }
     384             :                         break;
     385             :                 case ZEND_INTERNAL_FUNCTION:
     386           0 :                         return ((zend_internal_function *) EG(current_execute_data)->function_state.function)->function_name;
     387             :                         break;
     388             :                 default:
     389           0 :                         return NULL;
     390             :         }
     391             : }
     392             : /* }}} */
     393             : 
     394           0 : ZEND_API const char *zend_get_executed_filename(TSRMLS_D) /* {{{ */
     395             : {
     396           0 :         if (EG(active_op_array)) {
     397           0 :                 return EG(active_op_array)->filename;
     398             :         } else {
     399           0 :                 return "[no active file]";
     400             :         }
     401             : }
     402             : /* }}} */
     403             : 
     404           0 : ZEND_API uint zend_get_executed_lineno(TSRMLS_D) /* {{{ */
     405             : {
     406           0 :         if(EG(exception) && EG(opline_ptr) && active_opline->opcode == ZEND_HANDLE_EXCEPTION &&
     407           0 :                 active_opline->lineno == 0 && EG(opline_before_exception)) {
     408           0 :                 return EG(opline_before_exception)->lineno;
     409             :         }
     410           0 :         if (EG(opline_ptr)) {
     411           0 :                 return active_opline->lineno;
     412             :         } else {
     413           0 :                 return 0;
     414             :         }
     415             : }
     416             : /* }}} */
     417             : 
     418           0 : ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */
     419             : {
     420           0 :         return EG(in_execution);
     421             : }
     422             : /* }}} */
     423             : 
     424           0 : ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
     425             : {
     426             :         TSRMLS_FETCH();
     427           0 :         i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
     428           0 : }
     429             : /* }}} */
     430             : 
     431           0 : ZEND_API void _zval_internal_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
     432             : {
     433             : #if DEBUG_ZEND>=2
     434             :         printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr) - 1);
     435             : #endif
     436           0 :         Z_DELREF_PP(zval_ptr);
     437           0 :         if (Z_REFCOUNT_PP(zval_ptr) == 0) {
     438           0 :                 zval_internal_dtor(*zval_ptr);
     439           0 :                 free(*zval_ptr);
     440           0 :         } else if (Z_REFCOUNT_PP(zval_ptr) == 1) {
     441           0 :                 Z_UNSET_ISREF_PP(zval_ptr);
     442             :         }
     443           0 : }
     444             : /* }}} */
     445             : 
     446           0 : ZEND_API int zend_is_true(zval *op TSRMLS_DC) /* {{{ */
     447             : {
     448           0 :         return i_zend_is_true(op TSRMLS_CC);
     449             : }
     450             : /* }}} */
     451             : 
     452             : #include "../TSRM/tsrm_strtok_r.h"
     453             : 
     454             : #define IS_VISITED_CONSTANT                     0x80
     455             : #define IS_CONSTANT_VISITED(p)          (Z_TYPE_P(p) & IS_VISITED_CONSTANT)
     456             : #define Z_REAL_TYPE_P(p)                        (Z_TYPE_P(p) & ~IS_VISITED_CONSTANT)
     457             : #define MARK_CONSTANT_VISITED(p)        Z_TYPE_P(p) |= IS_VISITED_CONSTANT
     458             : 
     459           0 : ZEND_API int zval_update_constant_ex(zval **pp, zend_bool inline_change, zend_class_entry *scope TSRMLS_DC) /* {{{ */
     460             : {
     461           0 :         zval *p = *pp;
     462             :         zval const_value;
     463             :         char *colon;
     464             : 
     465           0 :         if (IS_CONSTANT_VISITED(p)) {
     466           0 :                 zend_error(E_ERROR, "Cannot declare self-referencing constant '%s'", Z_STRVAL_P(p));
     467           0 :         } else if ((Z_TYPE_P(p) & IS_CONSTANT_TYPE_MASK) == IS_CONSTANT) {
     468             :                 int refcount;
     469             :                 zend_uchar is_ref;
     470             : 
     471           0 :                 SEPARATE_ZVAL_IF_NOT_REF(pp);
     472           0 :                 p = *pp;
     473             : 
     474           0 :                 MARK_CONSTANT_VISITED(p);
     475             : 
     476           0 :                 refcount = Z_REFCOUNT_P(p);
     477           0 :                 is_ref = Z_ISREF_P(p);
     478             : 
     479           0 :                 if (!zend_get_constant_ex(p->value.str.val, p->value.str.len, &const_value, scope, Z_REAL_TYPE_P(p) TSRMLS_CC)) {
     480           0 :                         char *actual = Z_STRVAL_P(p);
     481             : 
     482           0 :                         if ((colon = (char*)zend_memrchr(Z_STRVAL_P(p), ':', Z_STRLEN_P(p)))) {
     483           0 :                                 zend_error(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(p));
     484           0 :                                 Z_STRLEN_P(p) -= ((colon - Z_STRVAL_P(p)) + 1);
     485           0 :                                 if (inline_change) {
     486           0 :                                         colon = estrndup(colon, Z_STRLEN_P(p));
     487           0 :                                         str_efree(Z_STRVAL_P(p));
     488           0 :                                         Z_STRVAL_P(p) = colon;
     489             :                                 } else {
     490           0 :                                         Z_STRVAL_P(p) = colon + 1;
     491             :                                 }
     492             :                         } else {
     493           0 :                                 char *save = actual, *slash;
     494           0 :                                 int actual_len = Z_STRLEN_P(p);
     495           0 :                                 if ((Z_TYPE_P(p) & IS_CONSTANT_UNQUALIFIED) && (slash = (char *)zend_memrchr(actual, '\\', actual_len))) {
     496           0 :                                         actual = slash + 1;
     497           0 :                                         actual_len -= (actual - Z_STRVAL_P(p));
     498           0 :                                         if (inline_change) {
     499           0 :                                                 actual = estrndup(actual, actual_len);
     500           0 :                                                 Z_STRVAL_P(p) = actual;
     501           0 :                                                 Z_STRLEN_P(p) = actual_len;
     502             :                                         }
     503             :                                 }
     504           0 :                                 if (actual[0] == '\\') {
     505           0 :                                         if (inline_change) {
     506           0 :                                                 memmove(Z_STRVAL_P(p), Z_STRVAL_P(p)+1, Z_STRLEN_P(p));
     507           0 :                                                 --Z_STRLEN_P(p);
     508             :                                         } else {
     509           0 :                                                 ++actual;
     510             :                                         }
     511           0 :                                         --actual_len;
     512             :                                 }
     513           0 :                                 if ((Z_TYPE_P(p) & IS_CONSTANT_UNQUALIFIED) == 0) {
     514           0 :                                         int fix_save = 0;
     515           0 :                                         if (save[0] == '\\') {
     516           0 :                                                 save++;
     517           0 :                                                 fix_save = 1;
     518             :                                         }
     519           0 :                                         zend_error(E_ERROR, "Undefined constant '%s'", save);
     520           0 :                                         if (fix_save) {
     521           0 :                                                 save--;
     522             :                                         }
     523           0 :                                         if (inline_change) {
     524           0 :                                                 str_efree(save);
     525             :                                         }
     526           0 :                                         save = NULL;
     527             :                                 }
     528           0 :                                 if (inline_change && save && save != actual) {
     529           0 :                                         str_efree(save);
     530             :                                 }
     531           0 :                                 zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'",  actual,  actual);
     532           0 :                                 p->type = IS_STRING;
     533           0 :                                 if (!inline_change) {
     534           0 :                                         Z_STRVAL_P(p) = actual;
     535           0 :                                         Z_STRLEN_P(p) = actual_len;
     536             :                                         zval_copy_ctor(p);
     537             :                                 }
     538             :                         }
     539             :                 } else {
     540           0 :                         if (inline_change) {
     541           0 :                                 str_efree(Z_STRVAL_P(p));
     542             :                         }
     543           0 :                         *p = const_value;
     544             :                 }
     545             : 
     546           0 :                 Z_SET_REFCOUNT_P(p, refcount);
     547           0 :                 Z_SET_ISREF_TO_P(p, is_ref);
     548           0 :         } else if (Z_TYPE_P(p) == IS_CONSTANT_AST) {
     549           0 :                 SEPARATE_ZVAL_IF_NOT_REF(pp);
     550           0 :                 p = *pp;
     551             : 
     552           0 :                 zend_ast_evaluate(&const_value, Z_AST_P(p), scope TSRMLS_CC);
     553           0 :                 if (inline_change) {
     554           0 :                         zend_ast_destroy(Z_AST_P(p));
     555             :                 }
     556           0 :                 ZVAL_COPY_VALUE(p, &const_value);
     557             :         }
     558           0 :         return 0;
     559             : }
     560             : /* }}} */
     561             : 
     562           0 : ZEND_API int zval_update_constant_inline_change(zval **pp, zend_class_entry *scope TSRMLS_DC) /* {{{ */
     563             : {
     564           0 :         return zval_update_constant_ex(pp, 1, scope TSRMLS_CC);
     565             : }
     566             : /* }}} */
     567             : 
     568           0 : ZEND_API int zval_update_constant_no_inline_change(zval **pp, zend_class_entry *scope TSRMLS_DC) /* {{{ */
     569             : {
     570           0 :         return zval_update_constant_ex(pp, 0, scope TSRMLS_CC);
     571             : }
     572             : /* }}} */
     573             : 
     574           0 : ZEND_API int zval_update_constant(zval **pp, zend_bool inline_change TSRMLS_DC) /* {{{ */
     575             : {
     576           0 :         return zval_update_constant_ex(pp, inline_change, NULL TSRMLS_CC);
     577             : }
     578             : /* }}} */
     579             : 
     580           0 : int call_user_function(HashTable *function_table, zval **object_pp, zval *function_name, zval *retval_ptr, zend_uint param_count, zval *params[] TSRMLS_DC) /* {{{ */
     581             : {
     582             :         zval ***params_array;
     583             :         zend_uint i;
     584             :         int ex_retval;
     585           0 :         zval *local_retval_ptr = NULL;
     586             : 
     587           0 :         if (param_count) {
     588           0 :                 params_array = (zval ***) emalloc(sizeof(zval **)*param_count);
     589           0 :                 for (i=0; i<param_count; i++) {
     590           0 :                         params_array[i] = &params[i];
     591             :                 }
     592             :         } else {
     593           0 :                 params_array = NULL;
     594             :         }
     595           0 :         ex_retval = call_user_function_ex(function_table, object_pp, function_name, &local_retval_ptr, param_count, params_array, 1, NULL TSRMLS_CC);
     596           0 :         if (local_retval_ptr) {
     597           0 :                 COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
     598             :         } else {
     599           0 :                 INIT_ZVAL(*retval_ptr);
     600             :         }
     601           0 :         if (params_array) {
     602           0 :                 efree(params_array);
     603             :         }
     604           0 :         return ex_retval;
     605             : }
     606             : /* }}} */
     607             : 
     608           0 : int call_user_function_ex(HashTable *function_table, zval **object_pp, zval *function_name, zval **retval_ptr_ptr, zend_uint param_count, zval **params[], int no_separation, HashTable *symbol_table TSRMLS_DC) /* {{{ */
     609             : {
     610             :         zend_fcall_info fci;
     611             : 
     612           0 :         fci.size = sizeof(fci);
     613           0 :         fci.function_table = function_table;
     614           0 :         fci.object_ptr = object_pp ? *object_pp : NULL;
     615           0 :         fci.function_name = function_name;
     616           0 :         fci.retval_ptr_ptr = retval_ptr_ptr;
     617           0 :         fci.param_count = param_count;
     618           0 :         fci.params = params;
     619           0 :         fci.no_separation = (zend_bool) no_separation;
     620           0 :         fci.symbol_table = symbol_table;
     621             : 
     622           0 :         return zend_call_function(&fci, NULL TSRMLS_CC);
     623             : }
     624             : /* }}} */
     625             : 
     626           0 : int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TSRMLS_DC) /* {{{ */
     627             : {
     628             :         zend_uint i;
     629             :         zval **original_return_value;
     630             :         HashTable *calling_symbol_table;
     631             :         zend_op_array *original_op_array;
     632             :         zend_op **original_opline_ptr;
     633             :         zend_class_entry *current_scope;
     634             :         zend_class_entry *current_called_scope;
     635           0 :         zend_class_entry *calling_scope = NULL;
     636           0 :         zend_class_entry *called_scope = NULL;
     637             :         zval *current_this;
     638             :         zend_execute_data execute_data;
     639             :         zend_fcall_info_cache fci_cache_local;
     640             : 
     641           0 :         *fci->retval_ptr_ptr = NULL;
     642             : 
     643           0 :         if (!EG(active)) {
     644           0 :                 return FAILURE; /* executor is already inactive */
     645             :         }
     646             : 
     647           0 :         if (EG(exception)) {
     648           0 :                 return FAILURE; /* we would result in an instable executor otherwise */
     649             :         }
     650             : 
     651           0 :         switch (fci->size) {
     652             :                 case sizeof(zend_fcall_info):
     653           0 :                         break; /* nothing to do currently */
     654             :                 default:
     655           0 :                         zend_error(E_ERROR, "Corrupted fcall_info provided to zend_call_function()");
     656             :                         break;
     657             :         }
     658             : 
     659             :         /* Initialize execute_data */
     660           0 :         if (EG(current_execute_data)) {
     661           0 :                 execute_data = *EG(current_execute_data);
     662           0 :                 EX(op_array) = NULL;
     663           0 :                 EX(opline) = NULL;
     664           0 :                 EX(object) = NULL;
     665             :         } else {
     666             :                 /* This only happens when we're called outside any execute()'s
     667             :                  * It shouldn't be strictly necessary to NULL execute_data out,
     668             :                  * but it may make bugs easier to spot
     669             :                  */
     670           0 :                 memset(&execute_data, 0, sizeof(zend_execute_data));
     671             :         }
     672             : 
     673           0 :         if (!fci_cache || !fci_cache->initialized) {
     674             :                 char *callable_name;
     675           0 :                 char *error = NULL;
     676             : 
     677           0 :                 if (!fci_cache) {
     678           0 :                         fci_cache = &fci_cache_local;
     679             :                 }
     680             : 
     681           0 :                 if (!zend_is_callable_ex(fci->function_name, fci->object_ptr, IS_CALLABLE_CHECK_SILENT, &callable_name, NULL, fci_cache, &error TSRMLS_CC)) {
     682           0 :                         if (error) {
     683           0 :                                 zend_error(E_WARNING, "Invalid callback %s, %s", callable_name, error);
     684           0 :                                 efree(error);
     685             :                         }
     686           0 :                         if (callable_name) {
     687           0 :                                 efree(callable_name);
     688             :                         }
     689           0 :                         return FAILURE;
     690           0 :                 } else if (error) {
     691             :                         /* Capitalize the first latter of the error message */
     692           0 :                         if (error[0] >= 'a' && error[0] <= 'z') {
     693           0 :                                 error[0] += ('A' - 'a');
     694             :                         }
     695           0 :                         zend_error(E_STRICT, "%s", error);
     696           0 :                         efree(error);
     697             :                 }
     698           0 :                 efree(callable_name);
     699             :         }
     700             : 
     701           0 :         EX(function_state).function = fci_cache->function_handler;
     702           0 :         calling_scope = fci_cache->calling_scope;
     703           0 :         called_scope = fci_cache->called_scope;
     704           0 :         fci->object_ptr = fci_cache->object_ptr;
     705           0 :         EX(object) = fci->object_ptr;
     706           0 :         if (fci->object_ptr && Z_TYPE_P(fci->object_ptr) == IS_OBJECT &&
     707           0 :             (!EG(objects_store).object_buckets || !EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(fci->object_ptr)].valid)) {
     708           0 :                 return FAILURE;
     709             :         }
     710             : 
     711           0 :         if (EX(function_state).function->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
     712           0 :                 if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) {
     713           0 :                         zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name);
     714             :                 }
     715           0 :                 if (EX(function_state).function->common.fn_flags & ZEND_ACC_DEPRECATED) {
     716           0 :                         zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
     717           0 :                                 EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
     718           0 :                                 EX(function_state).function->common.scope ? "::" : "",
     719           0 :                                 EX(function_state).function->common.function_name);
     720             :                 }
     721             :         }
     722             : 
     723           0 :         ZEND_VM_STACK_GROW_IF_NEEDED(fci->param_count + 1);
     724             : 
     725           0 :         for (i=0; i<fci->param_count; i++) {
     726             :                 zval *param;
     727             : 
     728           0 :                 if (ARG_SHOULD_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
     729           0 :                         if (!PZVAL_IS_REF(*fci->params[i]) && Z_REFCOUNT_PP(fci->params[i]) > 1) {
     730             :                                 zval *new_zval;
     731             : 
     732           0 :                                 if (fci->no_separation &&
     733           0 :                                     !ARG_MAY_BE_SENT_BY_REF(EX(function_state).function, i + 1)) {
     734           0 :                                         if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) {
     735             :                                                 /* hack to clean up the stack */
     736           0 :                                                 zend_vm_stack_push((void *) (zend_uintptr_t)i TSRMLS_CC);
     737             :                                                 zend_vm_stack_clear_multiple(0 TSRMLS_CC);
     738             :                                         }
     739             : 
     740           0 :                                         zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
     741             :                                                 i+1,
     742           0 :                                                 EX(function_state).function->common.scope ? EX(function_state).function->common.scope->name : "",
     743           0 :                                                 EX(function_state).function->common.scope ? "::" : "",
     744           0 :                                                 EX(function_state).function->common.function_name);
     745           0 :                                         return FAILURE;
     746             :                                 }
     747             : 
     748           0 :                                 ALLOC_ZVAL(new_zval);
     749           0 :                                 *new_zval = **fci->params[i];
     750             :                                 zval_copy_ctor(new_zval);
     751             :                                 Z_SET_REFCOUNT_P(new_zval, 1);
     752           0 :                                 Z_DELREF_PP(fci->params[i]);
     753           0 :                                 *fci->params[i] = new_zval;
     754             :                         }
     755           0 :                         Z_ADDREF_PP(fci->params[i]);
     756           0 :                         Z_SET_ISREF_PP(fci->params[i]);
     757           0 :                         param = *fci->params[i];
     758           0 :                 } else if (PZVAL_IS_REF(*fci->params[i]) &&
     759             :                            /* don't separate references for __call */
     760           0 :                            (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) == 0 ) {
     761           0 :                         ALLOC_ZVAL(param);
     762           0 :                         *param = **(fci->params[i]);
     763           0 :                         INIT_PZVAL(param);
     764             :                         zval_copy_ctor(param);
     765           0 :                 } else if (*fci->params[i] != &EG(uninitialized_zval)) {
     766           0 :                         Z_ADDREF_PP(fci->params[i]);
     767           0 :                         param = *fci->params[i];
     768             :                 } else {
     769           0 :                         ALLOC_ZVAL(param);
     770           0 :                         *param = **(fci->params[i]);
     771           0 :                         INIT_PZVAL(param);
     772             :                 }
     773             :                 zend_vm_stack_push(param TSRMLS_CC);
     774             :         }
     775             : 
     776           0 :         EX(function_state).arguments = zend_vm_stack_top(TSRMLS_C);
     777           0 :         zend_vm_stack_push((void*)(zend_uintptr_t)fci->param_count TSRMLS_CC);
     778             : 
     779           0 :         current_scope = EG(scope);
     780           0 :         EG(scope) = calling_scope;
     781             : 
     782           0 :         current_this = EG(This);
     783             : 
     784           0 :         current_called_scope = EG(called_scope);
     785           0 :         if (called_scope) {
     786           0 :                 EG(called_scope) = called_scope;
     787           0 :         } else if (EX(function_state).function->type != ZEND_INTERNAL_FUNCTION) {
     788           0 :                 EG(called_scope) = NULL;
     789             :         }
     790             : 
     791           0 :         if (fci->object_ptr) {
     792           0 :                 if ((EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) {
     793           0 :                         EG(This) = NULL;
     794             :                 } else {
     795           0 :                         EG(This) = fci->object_ptr;
     796             : 
     797           0 :                         if (!PZVAL_IS_REF(EG(This))) {
     798           0 :                                 Z_ADDREF_P(EG(This)); /* For $this pointer */
     799             :                         } else {
     800             :                                 zval *this_ptr;
     801             : 
     802           0 :                                 ALLOC_ZVAL(this_ptr);
     803           0 :                                 *this_ptr = *EG(This);
     804           0 :                                 INIT_PZVAL(this_ptr);
     805             :                                 zval_copy_ctor(this_ptr);
     806           0 :                                 EG(This) = this_ptr;
     807             :                         }
     808             :                 }
     809             :         } else {
     810           0 :                 EG(This) = NULL;
     811             :         }
     812             : 
     813           0 :         EX(prev_execute_data) = EG(current_execute_data);
     814           0 :         EG(current_execute_data) = &execute_data;
     815             : 
     816           0 :         if (EX(function_state).function->type == ZEND_USER_FUNCTION) {
     817           0 :                 calling_symbol_table = EG(active_symbol_table);
     818           0 :                 EG(scope) = EX(function_state).function->common.scope;
     819           0 :                 if (fci->symbol_table) {
     820           0 :                         EG(active_symbol_table) = fci->symbol_table;
     821             :                 } else {
     822           0 :                         EG(active_symbol_table) = NULL;
     823             :                 }
     824             : 
     825           0 :                 original_return_value = EG(return_value_ptr_ptr);
     826           0 :                 original_op_array = EG(active_op_array);
     827           0 :                 EG(return_value_ptr_ptr) = fci->retval_ptr_ptr;
     828           0 :                 EG(active_op_array) = (zend_op_array *) EX(function_state).function;
     829           0 :                 original_opline_ptr = EG(opline_ptr);
     830             : 
     831           0 :                 if (EG(active_op_array)->fn_flags & ZEND_ACC_GENERATOR) {
     832           0 :                         *fci->retval_ptr_ptr = zend_generator_create_zval(EG(active_op_array) TSRMLS_CC);
     833             :                 } else {
     834           0 :                         zend_execute(EG(active_op_array) TSRMLS_CC);
     835             :                 }
     836             : 
     837           0 :                 if (!fci->symbol_table && EG(active_symbol_table)) {
     838           0 :                         zend_clean_and_cache_symbol_table(EG(active_symbol_table) TSRMLS_CC);
     839             :                 }
     840           0 :                 EG(active_symbol_table) = calling_symbol_table;
     841           0 :                 EG(active_op_array) = original_op_array;
     842           0 :                 EG(return_value_ptr_ptr)=original_return_value;
     843           0 :                 EG(opline_ptr) = original_opline_ptr;
     844           0 :         } else if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) {
     845           0 :                 int call_via_handler = (EX(function_state).function->common.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0;
     846           0 :                 ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
     847           0 :                 if (EX(function_state).function->common.scope) {
     848           0 :                         EG(scope) = EX(function_state).function->common.scope;
     849             :                 }
     850           0 :                 if (EXPECTED(zend_execute_internal == NULL)) {
     851             :                         /* saves one function call if zend_execute_internal is not used */
     852           0 :                         EX(function_state).function->internal_function.handler(fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC);
     853             :                 } else {
     854           0 :                         zend_execute_internal(&execute_data, fci, 1 TSRMLS_CC);
     855             :                 }
     856             :                 /*  We shouldn't fix bad extensions here,
     857             :                         because it can break proper ones (Bug #34045)
     858             :                 if (!EX(function_state).function->common.return_reference)
     859             :                 {
     860             :                         INIT_PZVAL(*fci->retval_ptr_ptr);
     861             :                 }*/
     862           0 :                 if (EG(exception) && fci->retval_ptr_ptr) {
     863           0 :                         zval_ptr_dtor(fci->retval_ptr_ptr);
     864           0 :                         *fci->retval_ptr_ptr = NULL;
     865             :                 }
     866             : 
     867           0 :                 if (call_via_handler) {
     868             :                         /* We must re-initialize function again */
     869           0 :                         fci_cache->initialized = 0;
     870             :                 }
     871             :         } else { /* ZEND_OVERLOADED_FUNCTION */
     872           0 :                 ALLOC_INIT_ZVAL(*fci->retval_ptr_ptr);
     873             : 
     874             :                 /* Not sure what should be done here if it's a static method */
     875           0 :                 if (fci->object_ptr) {
     876           0 :                         Z_OBJ_HT_P(fci->object_ptr)->call_method(EX(function_state).function->common.function_name, fci->param_count, *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC);
     877             :                 } else {
     878           0 :                         zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
     879             :                 }
     880             : 
     881           0 :                 if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) {
     882           0 :                         efree((char*)EX(function_state).function->common.function_name);
     883             :                 }
     884           0 :                 efree(EX(function_state).function);
     885             : 
     886           0 :                 if (EG(exception) && fci->retval_ptr_ptr) {
     887           0 :                         zval_ptr_dtor(fci->retval_ptr_ptr);
     888           0 :                         *fci->retval_ptr_ptr = NULL;
     889             :                 }
     890             :         }
     891             :         zend_vm_stack_clear_multiple(0 TSRMLS_CC);
     892             : 
     893           0 :         if (EG(This)) {
     894           0 :                 zval_ptr_dtor(&EG(This));
     895             :         }
     896           0 :         EG(called_scope) = current_called_scope;
     897           0 :         EG(scope) = current_scope;
     898           0 :         EG(This) = current_this;
     899           0 :         EG(current_execute_data) = EX(prev_execute_data);
     900             : 
     901           0 :         if (EG(exception)) {
     902           0 :                 zend_throw_exception_internal(NULL TSRMLS_CC);
     903             :         }
     904           0 :         return SUCCESS;
     905             : }
     906             : /* }}} */
     907             : 
     908           0 : ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC) /* {{{ */
     909             : {
     910             :         zval **args[1];
     911             :         zval autoload_function;
     912             :         zval *class_name_ptr;
     913           0 :         zval *retval_ptr = NULL;
     914             :         int retval, lc_length;
     915             :         char *lc_name;
     916             :         char *lc_free;
     917             :         zend_fcall_info fcall_info;
     918             :         zend_fcall_info_cache fcall_cache;
     919           0 :         char dummy = 1;
     920             :         ulong hash;
     921             :         ALLOCA_FLAG(use_heap)
     922             : 
     923           0 :         if (key) {
     924           0 :                 lc_name = Z_STRVAL(key->constant);
     925           0 :                 lc_length = Z_STRLEN(key->constant) + 1;
     926           0 :                 hash = key->hash_value;
     927             :         } else {
     928           0 :                 if (name == NULL || !name_length) {
     929           0 :                         return FAILURE;
     930             :                 }
     931             : 
     932           0 :                 lc_free = lc_name = do_alloca(name_length + 1, use_heap);
     933           0 :                 zend_str_tolower_copy(lc_name, name, name_length);
     934           0 :                 lc_length = name_length + 1;
     935             : 
     936           0 :                 if (lc_name[0] == '\\') {
     937           0 :                         lc_name += 1;
     938           0 :                         lc_length -= 1;
     939             :                 }
     940             : 
     941           0 :                 hash = zend_inline_hash_func(lc_name, lc_length);
     942             :         }
     943             : 
     944           0 :         if (zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce) == SUCCESS) {
     945           0 :                 if (!key) {
     946           0 :                         free_alloca(lc_free, use_heap);
     947             :                 }
     948           0 :                 return SUCCESS;
     949             :         }
     950             : 
     951             :         /* The compiler is not-reentrant. Make sure we __autoload() only during run-time
     952             :          * (doesn't impact functionality of __autoload()
     953             :         */
     954           0 :         if (!use_autoload || zend_is_compiling(TSRMLS_C)) {
     955           0 :                 if (!key) {
     956           0 :                         free_alloca(lc_free, use_heap);
     957             :                 }
     958           0 :                 return FAILURE;
     959             :         }
     960             : 
     961             :         /* Verify class name before passing it to __autoload() */
     962           0 :         if (strspn(name, "0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\\") != name_length) {
     963           0 :                 if (!key) {
     964           0 :                         free_alloca(lc_free, use_heap);
     965             :                 }
     966           0 :                 return FAILURE;
     967             :         }
     968             :         
     969           0 :         if (EG(in_autoload) == NULL) {
     970           0 :                 ALLOC_HASHTABLE(EG(in_autoload));
     971           0 :                 zend_hash_init(EG(in_autoload), 0, NULL, NULL, 0);
     972             :         }
     973             : 
     974           0 :         if (zend_hash_quick_add(EG(in_autoload), lc_name, lc_length, hash, (void**)&dummy, sizeof(char), NULL) == FAILURE) {
     975           0 :                 if (!key) {
     976           0 :                         free_alloca(lc_free, use_heap);
     977             :                 }
     978           0 :                 return FAILURE;
     979             :         }
     980             : 
     981           0 :         ZVAL_STRINGL(&autoload_function, ZEND_AUTOLOAD_FUNC_NAME, sizeof(ZEND_AUTOLOAD_FUNC_NAME) - 1, 0);
     982             : 
     983           0 :         ALLOC_ZVAL(class_name_ptr);
     984           0 :         INIT_PZVAL(class_name_ptr);
     985           0 :         if (name[0] == '\\') {
     986           0 :                 ZVAL_STRINGL(class_name_ptr, name+1, name_length-1, 1);
     987             :         } else {
     988           0 :                 ZVAL_STRINGL(class_name_ptr, name, name_length, 1);
     989             :         }
     990             : 
     991           0 :         args[0] = &class_name_ptr;
     992             : 
     993           0 :         fcall_info.size = sizeof(fcall_info);
     994           0 :         fcall_info.function_table = EG(function_table);
     995           0 :         fcall_info.function_name = &autoload_function;
     996           0 :         fcall_info.symbol_table = NULL;
     997           0 :         fcall_info.retval_ptr_ptr = &retval_ptr;
     998           0 :         fcall_info.param_count = 1;
     999           0 :         fcall_info.params = args;
    1000           0 :         fcall_info.object_ptr = NULL;
    1001           0 :         fcall_info.no_separation = 1;
    1002             : 
    1003           0 :         fcall_cache.initialized = EG(autoload_func) ? 1 : 0;
    1004           0 :         fcall_cache.function_handler = EG(autoload_func);
    1005           0 :         fcall_cache.calling_scope = NULL;
    1006           0 :         fcall_cache.called_scope = NULL;
    1007           0 :         fcall_cache.object_ptr = NULL;
    1008             : 
    1009           0 :         zend_exception_save(TSRMLS_C);
    1010           0 :         retval = zend_call_function(&fcall_info, &fcall_cache TSRMLS_CC);
    1011           0 :         zend_exception_restore(TSRMLS_C);
    1012             : 
    1013           0 :         EG(autoload_func) = fcall_cache.function_handler;
    1014             : 
    1015           0 :         zval_ptr_dtor(&class_name_ptr);
    1016             : 
    1017           0 :         zend_hash_quick_del(EG(in_autoload), lc_name, lc_length, hash);
    1018             : 
    1019           0 :         if (retval_ptr) {
    1020           0 :                 zval_ptr_dtor(&retval_ptr);
    1021             :         }
    1022             : 
    1023           0 :         if (retval == SUCCESS) {
    1024           0 :                 retval = zend_hash_quick_find(EG(class_table), lc_name, lc_length, hash, (void **) ce);
    1025             :         }
    1026           0 :         if (!key) {
    1027           0 :                 free_alloca(lc_free, use_heap);
    1028             :         }
    1029           0 :         return retval;
    1030             : }
    1031             : /* }}} */
    1032             : 
    1033           0 : ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC) /* {{{ */
    1034             : {
    1035           0 :         return zend_lookup_class_ex(name, name_length, NULL, 1, ce TSRMLS_CC);
    1036             : }
    1037             : /* }}} */
    1038             : 
    1039           0 : ZEND_API int zend_eval_stringl(char *str, int str_len, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */
    1040             : {
    1041             :         zval pv;
    1042             :         zend_op_array *new_op_array;
    1043           0 :         zend_op_array *original_active_op_array = EG(active_op_array);
    1044             :         zend_uint original_compiler_options;
    1045             :         int retval;
    1046             : 
    1047           0 :         if (retval_ptr) {
    1048           0 :                 Z_STRLEN(pv) = str_len + sizeof("return ;") - 1;
    1049           0 :                 Z_STRVAL(pv) = emalloc(Z_STRLEN(pv) + 1);
    1050           0 :                 memcpy(Z_STRVAL(pv), "return ", sizeof("return ") - 1);
    1051           0 :                 memcpy(Z_STRVAL(pv) + sizeof("return ") - 1, str, str_len);
    1052           0 :                 Z_STRVAL(pv)[Z_STRLEN(pv) - 1] = ';';
    1053           0 :                 Z_STRVAL(pv)[Z_STRLEN(pv)] = '\0';
    1054             :         } else {
    1055           0 :                 Z_STRLEN(pv) = str_len;
    1056           0 :                 Z_STRVAL(pv) = str;
    1057             :         }
    1058           0 :         Z_TYPE(pv) = IS_STRING;
    1059             : 
    1060             :         /*printf("Evaluating '%s'\n", pv.value.str.val);*/
    1061             : 
    1062           0 :         original_compiler_options = CG(compiler_options);
    1063           0 :         CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
    1064           0 :         new_op_array = zend_compile_string(&pv, string_name TSRMLS_CC);
    1065           0 :         CG(compiler_options) = original_compiler_options;
    1066             : 
    1067           0 :         if (new_op_array) {
    1068           0 :                 zval *local_retval_ptr=NULL;
    1069           0 :                 zval **original_return_value_ptr_ptr = EG(return_value_ptr_ptr);
    1070           0 :                 zend_op **original_opline_ptr = EG(opline_ptr);
    1071           0 :                 int orig_interactive = CG(interactive);
    1072             : 
    1073           0 :                 EG(return_value_ptr_ptr) = &local_retval_ptr;
    1074           0 :                 EG(active_op_array) = new_op_array;
    1075           0 :                 EG(no_extensions)=1;
    1076           0 :                 if (!EG(active_symbol_table)) {
    1077           0 :                         zend_rebuild_symbol_table(TSRMLS_C);
    1078             :                 }
    1079           0 :                 CG(interactive) = 0;
    1080             : 
    1081           0 :                 zend_try {
    1082           0 :                         zend_execute(new_op_array TSRMLS_CC);
    1083           0 :                 } zend_catch {
    1084           0 :                         destroy_op_array(new_op_array TSRMLS_CC);
    1085           0 :                         efree(new_op_array);
    1086           0 :                         zend_bailout();
    1087           0 :                 } zend_end_try();
    1088             : 
    1089           0 :                 CG(interactive) = orig_interactive;
    1090           0 :                 if (local_retval_ptr) {
    1091           0 :                         if (retval_ptr) {
    1092           0 :                                 COPY_PZVAL_TO_ZVAL(*retval_ptr, local_retval_ptr);
    1093             :                         } else {
    1094           0 :                                 zval_ptr_dtor(&local_retval_ptr);
    1095             :                         }
    1096             :                 } else {
    1097           0 :                         if (retval_ptr) {
    1098           0 :                                 INIT_ZVAL(*retval_ptr);
    1099             :                         }
    1100             :                 }
    1101             : 
    1102           0 :                 EG(no_extensions)=0;
    1103           0 :                 EG(opline_ptr) = original_opline_ptr;
    1104           0 :                 EG(active_op_array) = original_active_op_array;
    1105           0 :                 destroy_op_array(new_op_array TSRMLS_CC);
    1106           0 :                 efree(new_op_array);
    1107           0 :                 EG(return_value_ptr_ptr) = original_return_value_ptr_ptr;
    1108           0 :                 retval = SUCCESS;
    1109             :         } else {
    1110           0 :                 retval = FAILURE;
    1111             :         }
    1112           0 :         if (retval_ptr) {
    1113             :                 zval_dtor(&pv);
    1114             :         }
    1115           0 :         return retval;
    1116             : }
    1117             : /* }}} */
    1118             : 
    1119           0 : ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC) /* {{{ */
    1120             : {
    1121           0 :         return zend_eval_stringl(str, strlen(str), retval_ptr, string_name TSRMLS_CC);
    1122             : }
    1123             : /* }}} */
    1124             : 
    1125           0 : ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
    1126             : {
    1127             :         int result;
    1128             : 
    1129           0 :         result = zend_eval_stringl(str, str_len, retval_ptr, string_name TSRMLS_CC);
    1130           0 :         if (handle_exceptions && EG(exception)) {
    1131           0 :                 zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
    1132           0 :                 result = FAILURE;
    1133             :         }
    1134           0 :         return result;
    1135             : }
    1136             : /* }}} */
    1137             : 
    1138           0 : ZEND_API int zend_eval_string_ex(char *str, zval *retval_ptr, char *string_name, int handle_exceptions TSRMLS_DC) /* {{{ */
    1139             : {
    1140           0 :         return zend_eval_stringl_ex(str, strlen(str), retval_ptr, string_name, handle_exceptions TSRMLS_CC);
    1141             : }
    1142             : /* }}} */
    1143             : 
    1144           0 : void execute_new_code(TSRMLS_D) /* {{{ */
    1145             : {
    1146             :         zend_op *opline, *end;
    1147             :         zend_op *ret_opline;
    1148             :         int orig_interactive;
    1149             : 
    1150           0 :         if (!(CG(active_op_array)->fn_flags & ZEND_ACC_INTERACTIVE)
    1151             :                 || CG(context).backpatch_count>0
    1152           0 :                 || CG(active_op_array)->function_name
    1153           0 :                 || CG(active_op_array)->type!=ZEND_USER_FUNCTION) {
    1154           0 :                 return;
    1155             :         }
    1156             : 
    1157           0 :         ret_opline = get_next_op(CG(active_op_array) TSRMLS_CC);
    1158           0 :         ret_opline->opcode = ZEND_RETURN;
    1159           0 :         ret_opline->op1_type = IS_CONST;
    1160           0 :         ret_opline->op1.constant = zend_add_literal(CG(active_op_array), &EG(uninitialized_zval) TSRMLS_CC);
    1161           0 :         SET_UNUSED(ret_opline->op2);
    1162             : 
    1163           0 :         if (!EG(start_op)) {
    1164           0 :                 EG(start_op) = CG(active_op_array)->opcodes;
    1165             :         }
    1166             : 
    1167           0 :         opline=EG(start_op);
    1168           0 :         end=CG(active_op_array)->opcodes+CG(active_op_array)->last;
    1169             : 
    1170           0 :         while (opline<end) {
    1171           0 :                 if (opline->op1_type == IS_CONST) {
    1172           0 :                         opline->op1.zv = &CG(active_op_array)->literals[opline->op1.constant].constant;
    1173             :                 }
    1174           0 :                 if (opline->op2_type == IS_CONST) {
    1175           0 :                         opline->op2.zv = &CG(active_op_array)->literals[opline->op2.constant].constant;
    1176             :                 }
    1177           0 :                 switch (opline->opcode) {
    1178             :                         case ZEND_GOTO:
    1179           0 :                                 if (Z_TYPE_P(opline->op2.zv) != IS_LONG) {
    1180           0 :                                         zend_resolve_goto_label(CG(active_op_array), opline, 1 TSRMLS_CC);
    1181             :                                 }
    1182             :                                 /* break omitted intentionally */
    1183             :                         case ZEND_JMP:
    1184           0 :                                 opline->op1.jmp_addr = &CG(active_op_array)->opcodes[opline->op1.opline_num];
    1185           0 :                                 break;
    1186             :                         case ZEND_JMPZ:
    1187             :                         case ZEND_JMPNZ:
    1188             :                         case ZEND_JMPZ_EX:
    1189             :                         case ZEND_JMPNZ_EX:
    1190             :                         case ZEND_JMP_SET:
    1191             :                         case ZEND_JMP_SET_VAR:
    1192           0 :                                 opline->op2.jmp_addr = &CG(active_op_array)->opcodes[opline->op2.opline_num];
    1193             :                                 break;
    1194             :                 }
    1195           0 :                 ZEND_VM_SET_OPCODE_HANDLER(opline);
    1196           0 :                 opline++;
    1197             :         }
    1198             : 
    1199           0 :         zend_release_labels(1 TSRMLS_CC);
    1200             : 
    1201           0 :         EG(return_value_ptr_ptr) = NULL;
    1202           0 :         EG(active_op_array) = CG(active_op_array);
    1203           0 :         orig_interactive = CG(interactive);
    1204           0 :         CG(interactive) = 0;
    1205           0 :         zend_execute(CG(active_op_array) TSRMLS_CC);
    1206           0 :         CG(interactive) = orig_interactive;
    1207             : 
    1208           0 :         if (EG(exception)) {
    1209           0 :                 zend_exception_error(EG(exception), E_ERROR TSRMLS_CC);
    1210             :         }
    1211             : 
    1212           0 :         CG(active_op_array)->last -= 1;      /* get rid of that ZEND_RETURN */
    1213           0 :         EG(start_op) = CG(active_op_array)->opcodes+CG(active_op_array)->last;
    1214             : }
    1215             : /* }}} */
    1216             : 
    1217           0 : ZEND_API void zend_timeout(int dummy) /* {{{ */
    1218             : {
    1219             :         TSRMLS_FETCH();
    1220             : 
    1221           0 :         if (zend_on_timeout) {
    1222             : #ifdef ZEND_SIGNALS
    1223             :                 /*
    1224             :                    We got here because we got a timeout signal, so we are in a signal handler
    1225             :                    at this point. However, we want to be able to timeout any user-supplied
    1226             :                    shutdown functions, so pretend we are not in a signal handler while we are
    1227             :                    calling these
    1228             :                 */
    1229             :                 SIGG(running) = 0;
    1230             : #endif
    1231           0 :                 zend_on_timeout(EG(timeout_seconds) TSRMLS_CC);
    1232             :         }
    1233             : 
    1234           0 :         zend_error(E_ERROR, "Maximum execution time of %d second%s exceeded", EG(timeout_seconds), EG(timeout_seconds) == 1 ? "" : "s");
    1235           0 : }
    1236             : /* }}} */
    1237             : 
    1238             : #ifdef ZEND_WIN32
    1239             : static LRESULT CALLBACK zend_timeout_WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) /* {{{ */
    1240             : {
    1241             :         switch (message) {
    1242             :                 case WM_DESTROY:
    1243             :                         PostQuitMessage(0);
    1244             :                         break;
    1245             :                 case WM_REGISTER_ZEND_TIMEOUT:
    1246             :                         /* wParam is the thread id pointer, lParam is the timeout amount in seconds */
    1247             :                         if (lParam == 0) {
    1248             :                                 KillTimer(timeout_window, wParam);
    1249             :                         } else {
    1250             : #ifdef ZTS
    1251             :                                 void ***tsrm_ls;
    1252             : #endif
    1253             :                                 SetTimer(timeout_window, wParam, lParam*1000, NULL);
    1254             : #ifdef ZTS
    1255             :                                 tsrm_ls = ts_resource_ex(0, &wParam);
    1256             :                                 if (!tsrm_ls) {
    1257             :                                         /* shouldn't normally happen */
    1258             :                                         break;
    1259             :                                 }
    1260             : #endif
    1261             :                                 EG(timed_out) = 0;
    1262             :                         }
    1263             :                         break;
    1264             :                 case WM_UNREGISTER_ZEND_TIMEOUT:
    1265             :                         /* wParam is the thread id pointer */
    1266             :                         KillTimer(timeout_window, wParam);
    1267             :                         break;
    1268             :                 case WM_TIMER: {
    1269             : #ifdef ZTS
    1270             :                                 void ***tsrm_ls;
    1271             : 
    1272             :                                 tsrm_ls = ts_resource_ex(0, &wParam);
    1273             :                                 if (!tsrm_ls) {
    1274             :                                         /* Thread died before receiving its timeout? */
    1275             :                                         break;
    1276             :                                 }
    1277             : #endif
    1278             :                                 KillTimer(timeout_window, wParam);
    1279             :                                 EG(timed_out) = 1;
    1280             :                         }
    1281             :                         break;
    1282             :                 default:
    1283             :                         return DefWindowProc(hWnd, message, wParam, lParam);
    1284             :         }
    1285             :         return 0;
    1286             : }
    1287             : /* }}} */
    1288             : 
    1289             : static unsigned __stdcall timeout_thread_proc(void *pArgs) /* {{{ */
    1290             : {
    1291             :         MSG message;
    1292             : 
    1293             :         wc.style=0;
    1294             :         wc.lpfnWndProc = zend_timeout_WndProc;
    1295             :         wc.cbClsExtra=0;
    1296             :         wc.cbWndExtra=0;
    1297             :         wc.hInstance=NULL;
    1298             :         wc.hIcon=NULL;
    1299             :         wc.hCursor=NULL;
    1300             :         wc.hbrBackground=(HBRUSH)(COLOR_BACKGROUND + 5);
    1301             :         wc.lpszMenuName=NULL;
    1302             :         wc.lpszClassName = "Zend Timeout Window";
    1303             :         if (!RegisterClass(&wc)) {
    1304             :                 return -1;
    1305             :         }
    1306             :         timeout_window = CreateWindow(wc.lpszClassName, wc.lpszClassName, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL);
    1307             :         SetEvent(timeout_thread_event);
    1308             :         while (GetMessage(&message, NULL, 0, 0)) {
    1309             :                 SendMessage(timeout_window, message.message, message.wParam, message.lParam);
    1310             :                 if (message.message == WM_QUIT) {
    1311             :                         break;
    1312             :                 }
    1313             :         }
    1314             :         DestroyWindow(timeout_window);
    1315             :         UnregisterClass(wc.lpszClassName, NULL);
    1316             :         SetEvent(timeout_thread_handle);
    1317             :         return 0;
    1318             : }
    1319             : /* }}} */
    1320             : 
    1321             : void zend_init_timeout_thread(void) /* {{{ */
    1322             : {
    1323             :         timeout_thread_event = CreateEvent(NULL, FALSE, FALSE, NULL);
    1324             :         timeout_thread_handle = CreateEvent(NULL, FALSE, FALSE, NULL);
    1325             :         _beginthreadex(NULL, 0, timeout_thread_proc, NULL, 0, &timeout_thread_id);
    1326             :         WaitForSingleObject(timeout_thread_event, INFINITE);
    1327             : }
    1328             : /* }}} */
    1329             : 
    1330             : void zend_shutdown_timeout_thread(void) /* {{{ */
    1331             : {
    1332             :         if (!timeout_thread_initialized) {
    1333             :                 return;
    1334             :         }
    1335             :         PostThreadMessage(timeout_thread_id, WM_QUIT, 0, 0);
    1336             : 
    1337             :         /* Wait for thread termination */
    1338             :         WaitForSingleObject(timeout_thread_handle, 5000);
    1339             :         CloseHandle(timeout_thread_handle);
    1340             :         timeout_thread_initialized = 0;
    1341             : }
    1342             : /* }}} */
    1343             : 
    1344             : #endif
    1345             : 
    1346             : /* This one doesn't exists on QNX */
    1347             : #ifndef SIGPROF
    1348             : #define SIGPROF 27
    1349             : #endif
    1350             : 
    1351           0 : void zend_set_timeout(long seconds, int reset_signals) /* {{{ */
    1352             : {
    1353             :         TSRMLS_FETCH();
    1354             : 
    1355           0 :         EG(timeout_seconds) = seconds;
    1356             : 
    1357             : #ifdef ZEND_WIN32
    1358             :         if(!seconds) {
    1359             :                 return;
    1360             :         }
    1361             :         if (timeout_thread_initialized == 0 && InterlockedIncrement(&timeout_thread_initialized) == 1) {
    1362             :                 /* We start up this process-wide thread here and not in zend_startup(), because if Zend
    1363             :                  * is initialized inside a DllMain(), you're not supposed to start threads from it.
    1364             :                  */
    1365             :                 zend_init_timeout_thread();
    1366             :         }
    1367             :         PostThreadMessage(timeout_thread_id, WM_REGISTER_ZEND_TIMEOUT, (WPARAM) GetCurrentThreadId(), (LPARAM) seconds);
    1368             : #else
    1369             : #       ifdef HAVE_SETITIMER
    1370             :         {
    1371             :                 struct itimerval t_r;           /* timeout requested */
    1372             :                 int signo;
    1373             : 
    1374           0 :                 if(seconds) {
    1375           0 :                         t_r.it_value.tv_sec = seconds;
    1376           0 :                         t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
    1377             : 
    1378             : #       ifdef __CYGWIN__
    1379             :                         setitimer(ITIMER_REAL, &t_r, NULL);
    1380             :                 }
    1381             :                 signo = SIGALRM;
    1382             : #       else
    1383           0 :                         setitimer(ITIMER_PROF, &t_r, NULL);
    1384             :                 }
    1385           0 :                 signo = SIGPROF;
    1386             : #       endif
    1387             : 
    1388           0 :                 if (reset_signals) {
    1389             : #       ifdef ZEND_SIGNALS
    1390             :                         zend_signal(signo, zend_timeout TSRMLS_CC);
    1391             : #       else
    1392             :                         sigset_t sigset;
    1393             : 
    1394           0 :                         signal(signo, zend_timeout);
    1395           0 :                         sigemptyset(&sigset);
    1396           0 :                         sigaddset(&sigset, signo);
    1397           0 :                         sigprocmask(SIG_UNBLOCK, &sigset, NULL);
    1398             : #       endif
    1399             :                 }
    1400             :         }
    1401             : #       endif /* HAVE_SETITIMER */
    1402             : #endif
    1403           0 : }
    1404             : /* }}} */
    1405             : 
    1406           0 : void zend_unset_timeout(TSRMLS_D) /* {{{ */
    1407             : {
    1408             : #ifdef ZEND_WIN32
    1409             :         if(timeout_thread_initialized) {
    1410             :                 PostThreadMessage(timeout_thread_id, WM_UNREGISTER_ZEND_TIMEOUT, (WPARAM) GetCurrentThreadId(), (LPARAM) 0);
    1411             :         }
    1412             : #else
    1413             : #       ifdef HAVE_SETITIMER
    1414           0 :         if (EG(timeout_seconds)) {
    1415             :                 struct itimerval no_timeout;
    1416             : 
    1417           0 :                 no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
    1418             : 
    1419             : #ifdef __CYGWIN__
    1420             :                 setitimer(ITIMER_REAL, &no_timeout, NULL);
    1421             : #else
    1422           0 :                 setitimer(ITIMER_PROF, &no_timeout, NULL);
    1423             : #endif
    1424             :         }
    1425             : #       endif
    1426             : #endif
    1427           0 : }
    1428             : /* }}} */
    1429             : 
    1430           0 : zend_class_entry *zend_fetch_class(const char *class_name, uint class_name_len, int fetch_type TSRMLS_DC) /* {{{ */
    1431             : {
    1432             :         zend_class_entry **pce;
    1433           0 :         int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
    1434           0 :         int silent       = (fetch_type & ZEND_FETCH_CLASS_SILENT) != 0;
    1435             : 
    1436           0 :         fetch_type &= ZEND_FETCH_CLASS_MASK;
    1437             : 
    1438             : check_fetch_type:
    1439           0 :         switch (fetch_type) {
    1440             :                 case ZEND_FETCH_CLASS_SELF:
    1441           0 :                         if (!EG(scope)) {
    1442           0 :                                 zend_error(E_ERROR, "Cannot access self:: when no class scope is active");
    1443             :                         }
    1444           0 :                         return EG(scope);
    1445             :                 case ZEND_FETCH_CLASS_PARENT:
    1446           0 :                         if (!EG(scope)) {
    1447           0 :                                 zend_error(E_ERROR, "Cannot access parent:: when no class scope is active");
    1448             :                         }
    1449           0 :                         if (!EG(scope)->parent) {
    1450           0 :                                 zend_error(E_ERROR, "Cannot access parent:: when current class scope has no parent");
    1451             :                         }
    1452           0 :                         return EG(scope)->parent;
    1453             :                 case ZEND_FETCH_CLASS_STATIC:
    1454           0 :                         if (!EG(called_scope)) {
    1455           0 :                                 zend_error(E_ERROR, "Cannot access static:: when no class scope is active");
    1456             :                         }
    1457           0 :                         return EG(called_scope);
    1458             :                 case ZEND_FETCH_CLASS_AUTO: {
    1459           0 :                                 fetch_type = zend_get_class_fetch_type(class_name, class_name_len);
    1460           0 :                                 if (fetch_type!=ZEND_FETCH_CLASS_DEFAULT) {
    1461           0 :                                         goto check_fetch_type;
    1462             :                                 }
    1463             :                         }
    1464             :                         break;
    1465             :         }
    1466             : 
    1467           0 :         if (zend_lookup_class_ex(class_name, class_name_len, NULL, use_autoload, &pce TSRMLS_CC) == FAILURE) {
    1468           0 :                 if (use_autoload) {
    1469           0 :                         if (!silent && !EG(exception)) {
    1470           0 :                                 if (fetch_type == ZEND_FETCH_CLASS_INTERFACE) {
    1471           0 :                                         zend_error(E_ERROR, "Interface '%s' not found", class_name);
    1472           0 :                                 } else if (fetch_type == ZEND_FETCH_CLASS_TRAIT) {
    1473           0 :                         zend_error(E_ERROR, "Trait '%s' not found", class_name);
    1474             :                 } else {
    1475           0 :                                         zend_error(E_ERROR, "Class '%s' not found", class_name);
    1476             :                                 }
    1477             :                         }
    1478             :                 }
    1479           0 :                 return NULL;
    1480             :         }
    1481           0 :         return *pce;
    1482             : }
    1483             : /* }}} */
    1484             : 
    1485           0 : zend_class_entry *zend_fetch_class_by_name(const char *class_name, uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC) /* {{{ */
    1486             : {
    1487             :         zend_class_entry **pce;
    1488           0 :         int use_autoload = (fetch_type & ZEND_FETCH_CLASS_NO_AUTOLOAD) == 0;
    1489             : 
    1490           0 :         if (zend_lookup_class_ex(class_name, class_name_len, key, use_autoload, &pce TSRMLS_CC) == FAILURE) {
    1491           0 :                 if (use_autoload) {
    1492           0 :                         if ((fetch_type & ZEND_FETCH_CLASS_SILENT) == 0 && !EG(exception)) {
    1493           0 :                                 if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_INTERFACE) {
    1494           0 :                                         zend_error(E_ERROR, "Interface '%s' not found", class_name);
    1495           0 :                                 } else if ((fetch_type & ZEND_FETCH_CLASS_MASK) == ZEND_FETCH_CLASS_TRAIT) {
    1496           0 :                                         zend_error(E_ERROR, "Trait '%s' not found", class_name);
    1497             :                                 } else {
    1498           0 :                                         zend_error(E_ERROR, "Class '%s' not found", class_name);
    1499             :                                 }
    1500             :                         }
    1501             :                 }
    1502           0 :                 return NULL;
    1503             :         }
    1504           0 :         return *pce;
    1505             : }
    1506             : /* }}} */
    1507             : 
    1508             : #define MAX_ABSTRACT_INFO_CNT 3
    1509             : #define MAX_ABSTRACT_INFO_FMT "%s%s%s%s"
    1510             : #define DISPLAY_ABSTRACT_FN(idx) \
    1511             :         ai.afn[idx] ? ZEND_FN_SCOPE_NAME(ai.afn[idx]) : "", \
    1512             :         ai.afn[idx] ? "::" : "", \
    1513             :         ai.afn[idx] ? ai.afn[idx]->common.function_name : "", \
    1514             :         ai.afn[idx] && ai.afn[idx + 1] ? ", " : (ai.afn[idx] && ai.cnt > MAX_ABSTRACT_INFO_CNT ? ", ..." : "")
    1515             : 
    1516             : typedef struct _zend_abstract_info {
    1517             :         zend_function *afn[MAX_ABSTRACT_INFO_CNT + 1];
    1518             :         int cnt;
    1519             :         int ctor;
    1520             : } zend_abstract_info;
    1521             : 
    1522           0 : static int zend_verify_abstract_class_function(zend_function *fn, zend_abstract_info *ai TSRMLS_DC) /* {{{ */
    1523             : {
    1524           0 :         if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
    1525           0 :                 if (ai->cnt < MAX_ABSTRACT_INFO_CNT) {
    1526           0 :                         ai->afn[ai->cnt] = fn;
    1527             :                 }
    1528           0 :                 if (fn->common.fn_flags & ZEND_ACC_CTOR) {
    1529           0 :                         if (!ai->ctor) {
    1530           0 :                                 ai->cnt++;
    1531           0 :                                 ai->ctor = 1;
    1532             :                         } else {
    1533           0 :                                 ai->afn[ai->cnt] = NULL;
    1534             :                         }
    1535             :                 } else {
    1536           0 :                         ai->cnt++;
    1537             :                 }
    1538             :         }
    1539           0 :         return 0;
    1540             : }
    1541             : /* }}} */
    1542             : 
    1543           0 : void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC) /* {{{ */
    1544             : {
    1545             :         zend_abstract_info ai;
    1546             : 
    1547           0 :         if ((ce->ce_flags & ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) && !(ce->ce_flags & ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
    1548           0 :                 memset(&ai, 0, sizeof(ai));
    1549             : 
    1550           0 :                 zend_hash_apply_with_argument(&ce->function_table, (apply_func_arg_t) zend_verify_abstract_class_function, &ai TSRMLS_CC);
    1551             : 
    1552           0 :                 if (ai.cnt) {
    1553           0 :                         zend_error(E_ERROR, "Class %s contains %d abstract method%s and must therefore be declared abstract or implement the remaining methods (" MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT MAX_ABSTRACT_INFO_FMT ")",
    1554             :                                 ce->name, ai.cnt,
    1555           0 :                                 ai.cnt > 1 ? "s" : "",
    1556           0 :                                 DISPLAY_ABSTRACT_FN(0),
    1557           0 :                                 DISPLAY_ABSTRACT_FN(1),
    1558           0 :                                 DISPLAY_ABSTRACT_FN(2)
    1559             :                                 );
    1560             :                 }
    1561             :         }
    1562           0 : }
    1563             : /* }}} */
    1564             : 
    1565           0 : ZEND_API void zend_reset_all_cv(HashTable *symbol_table TSRMLS_DC) /* {{{ */
    1566             : {
    1567             :         zend_execute_data *ex;
    1568             :         int i;
    1569             : 
    1570           0 :         for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {
    1571           0 :                 if (ex->op_array && ex->symbol_table == symbol_table) {
    1572           0 :                         for (i = 0; i < ex->op_array->last_var; i++) {
    1573           0 :                                 *EX_CV_NUM(ex, i) = NULL;
    1574             :                         }
    1575             :                 }
    1576             :         }
    1577           0 : }
    1578             : /* }}} */
    1579             : 
    1580           0 : ZEND_API void zend_delete_variable(zend_execute_data *ex, HashTable *ht, const char *name, int name_len, ulong hash_value TSRMLS_DC) /* {{{ */
    1581             : {
    1582           0 :         if (zend_hash_quick_del(ht, name, name_len, hash_value) == SUCCESS) {
    1583           0 :                 name_len--;
    1584           0 :                 while (ex && ex->symbol_table == ht) {
    1585             :                         int i;
    1586             : 
    1587           0 :                         if (ex->op_array) {
    1588           0 :                                 for (i = 0; i < ex->op_array->last_var; i++) {
    1589           0 :                                         if (ex->op_array->vars[i].hash_value == hash_value &&
    1590           0 :                                                 ex->op_array->vars[i].name_len == name_len &&
    1591           0 :                                                 !memcmp(ex->op_array->vars[i].name, name, name_len)) {
    1592           0 :                                                 *EX_CV_NUM(ex, i) = NULL;
    1593           0 :                                                 break;
    1594             :                                         }
    1595             :                                 }
    1596             :                         }
    1597           0 :                         ex = ex->prev_execute_data;
    1598             :                 }
    1599             :         }
    1600           0 : }
    1601             : /* }}} */
    1602             : 
    1603           0 : ZEND_API int zend_delete_global_variable_ex(const char *name, int name_len, ulong hash_value TSRMLS_DC) /* {{{ */
    1604             : {
    1605             :         zend_execute_data *ex;
    1606             : 
    1607           0 :         if (zend_hash_quick_exists(&EG(symbol_table), name, name_len + 1, hash_value)) {
    1608           0 :                 for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {
    1609           0 :                         if (ex->op_array && ex->symbol_table == &EG(symbol_table)) {
    1610             :                                 int i;
    1611           0 :                                 for (i = 0; i < ex->op_array->last_var; i++) {
    1612           0 :                                         if (ex->op_array->vars[i].hash_value == hash_value &&
    1613           0 :                                                 ex->op_array->vars[i].name_len == name_len &&
    1614           0 :                                                 !memcmp(ex->op_array->vars[i].name, name, name_len)
    1615             :                                         ) {
    1616           0 :                                                 *EX_CV_NUM(ex, i) = NULL;
    1617           0 :                                                 break;
    1618             :                                         }
    1619             :                                 }
    1620             :                         }
    1621             :                 }
    1622           0 :                 return zend_hash_quick_del(&EG(symbol_table), name, name_len + 1, hash_value);
    1623             :         }
    1624           0 :         return FAILURE;
    1625             : }
    1626             : /* }}} */
    1627             : 
    1628           0 : ZEND_API int zend_delete_global_variable(const char *name, int name_len TSRMLS_DC) /* {{{ */
    1629             : {
    1630           0 :         return zend_delete_global_variable_ex(name, name_len, zend_inline_hash_func(name, name_len + 1) TSRMLS_CC);
    1631             : }
    1632             : /* }}} */
    1633             : 
    1634           0 : ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
    1635             : {
    1636             :         zend_uint i;
    1637             :         zend_execute_data *ex;
    1638             : 
    1639           0 :         if (!EG(active_symbol_table)) {
    1640             : 
    1641             :                 /* Search for last called user function */
    1642           0 :                 ex = EG(current_execute_data);
    1643           0 :                 while (ex && !ex->op_array) {
    1644           0 :                         ex = ex->prev_execute_data;
    1645             :                 }
    1646           0 :                 if (ex && ex->symbol_table) {
    1647           0 :                         EG(active_symbol_table) = ex->symbol_table;
    1648           0 :                         return;
    1649             :                 }
    1650             : 
    1651           0 :                 if (ex && ex->op_array) {
    1652           0 :                         if (EG(symtable_cache_ptr)>=EG(symtable_cache)) {
    1653             :                                 /*printf("Cache hit!  Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/
    1654           0 :                                 EG(active_symbol_table) = *(EG(symtable_cache_ptr)--);
    1655             :                         } else {
    1656           0 :                                 ALLOC_HASHTABLE(EG(active_symbol_table));
    1657           0 :                                 zend_hash_init(EG(active_symbol_table), ex->op_array->last_var, NULL, ZVAL_PTR_DTOR, 0);
    1658             :                                 /*printf("Cache miss!  Initialized %x\n", EG(active_symbol_table));*/
    1659             :                         }
    1660           0 :                         ex->symbol_table = EG(active_symbol_table);
    1661             : 
    1662           0 :                         if (ex->op_array->this_var != -1 &&
    1663           0 :                             !*EX_CV_NUM(ex, ex->op_array->this_var) &&
    1664           0 :                             EG(This)) {
    1665           0 :                             *EX_CV_NUM(ex, ex->op_array->this_var) = (zval**)EX_CV_NUM(ex, ex->op_array->last_var + ex->op_array->this_var);
    1666           0 :                                 **EX_CV_NUM(ex, ex->op_array->this_var) = EG(This);
    1667             :                         }
    1668           0 :                         for (i = 0; i < ex->op_array->last_var; i++) {
    1669           0 :                                 if (*EX_CV_NUM(ex, i)) {
    1670           0 :                                         zend_hash_quick_update(EG(active_symbol_table),
    1671             :                                                 ex->op_array->vars[i].name,
    1672             :                                                 ex->op_array->vars[i].name_len + 1,
    1673             :                                                 ex->op_array->vars[i].hash_value,
    1674             :                                                 (void**)*EX_CV_NUM(ex, i),
    1675             :                                                 sizeof(zval*),
    1676             :                                                 (void**)EX_CV_NUM(ex, i));
    1677             :                                 }
    1678             :                         }
    1679             :                 }
    1680             :         }
    1681             : }
    1682             : /* }}} */
    1683             : 
    1684             : /*
    1685             :  * Local variables:
    1686             :  * tab-width: 4
    1687             :  * c-basic-offset: 4
    1688             :  * indent-tabs-mode: t
    1689             :  * End:
    1690             :  */

Generated by: LCOV version 1.10

Generated at Wed, 16 Apr 2014 12:47:44 +0000 (7 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.