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.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 481 534 90.1 %
Date: 2016-09-27 Functions: 43 45 95.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2016 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 "zend.h"
      23             : #include "zend_extensions.h"
      24             : #include "zend_modules.h"
      25             : #include "zend_constants.h"
      26             : #include "zend_list.h"
      27             : #include "zend_API.h"
      28             : #include "zend_exceptions.h"
      29             : #include "zend_builtin_functions.h"
      30             : #include "zend_ini.h"
      31             : #include "zend_vm.h"
      32             : #include "zend_dtrace.h"
      33             : #include "zend_virtual_cwd.h"
      34             : #include "zend_smart_str.h"
      35             : 
      36             : #ifdef ZTS
      37             : # define GLOBAL_FUNCTION_TABLE          global_function_table
      38             : # define GLOBAL_CLASS_TABLE                     global_class_table
      39             : # define GLOBAL_CONSTANTS_TABLE         global_constants_table
      40             : # define GLOBAL_AUTO_GLOBALS_TABLE      global_auto_globals_table
      41             : #else
      42             : # define GLOBAL_FUNCTION_TABLE          CG(function_table)
      43             : # define GLOBAL_CLASS_TABLE                     CG(class_table)
      44             : # define GLOBAL_AUTO_GLOBALS_TABLE      CG(auto_globals)
      45             : # define GLOBAL_CONSTANTS_TABLE         EG(zend_constants)
      46             : #endif
      47             : 
      48             : /* true multithread-shared globals */
      49             : ZEND_API zend_class_entry *zend_standard_class_def = NULL;
      50             : ZEND_API size_t (*zend_printf)(const char *format, ...);
      51             : ZEND_API zend_write_func_t zend_write;
      52             : ZEND_API FILE *(*zend_fopen)(const char *filename, zend_string **opened_path);
      53             : ZEND_API int (*zend_stream_open_function)(const char *filename, zend_file_handle *handle);
      54             : ZEND_API void (*zend_ticks_function)(int ticks);
      55             : ZEND_API void (*zend_interrupt_function)(zend_execute_data *execute_data);
      56             : ZEND_API void (*zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);
      57             : size_t (*zend_vspprintf)(char **pbuf, size_t max_len, const char *format, va_list ap);
      58             : zend_string *(*zend_vstrpprintf)(size_t max_len, const char *format, va_list ap);
      59             : ZEND_API char *(*zend_getenv)(char *name, size_t name_len);
      60             : ZEND_API zend_string *(*zend_resolve_path)(const char *filename, int filename_len);
      61             : 
      62             : void (*zend_on_timeout)(int seconds);
      63             : 
      64             : static void (*zend_message_dispatcher_p)(zend_long message, const void *data);
      65             : static zval *(*zend_get_configuration_directive_p)(zend_string *name);
      66             : 
      67       27108 : static ZEND_INI_MH(OnUpdateErrorReporting) /* {{{ */
      68             : {
      69       27108 :         if (!new_value) {
      70         202 :                 EG(error_reporting) = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED;
      71             :         } else {
      72       26906 :                 EG(error_reporting) = atoi(ZSTR_VAL(new_value));
      73             :         }
      74       27108 :         return SUCCESS;
      75             : }
      76             : /* }}} */
      77             : 
      78       23972 : static ZEND_INI_MH(OnUpdateGCEnabled) /* {{{ */
      79             : {
      80       23972 :         OnUpdateBool(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
      81             : 
      82       23972 :         if (GC_G(gc_enabled)) {
      83       23964 :                 gc_init();
      84             :         }
      85             : 
      86       23972 :         return SUCCESS;
      87             : }
      88             : /* }}} */
      89             : 
      90       23950 : static ZEND_INI_MH(OnUpdateScriptEncoding) /* {{{ */
      91             : {
      92       23950 :         if (!CG(multibyte)) {
      93       23904 :                 return FAILURE;
      94             :         }
      95          46 :         if (!zend_multibyte_get_functions()) {
      96          46 :                 return SUCCESS;
      97             :         }
      98           0 :         return zend_multibyte_set_script_encoding_by_string(new_value ? ZSTR_VAL(new_value) : NULL, new_value ? ZSTR_LEN(new_value) : 0);
      99             : }
     100             : /* }}} */
     101             : 
     102       23963 : static ZEND_INI_MH(OnUpdateAssertions) /* {{{ */
     103             : {
     104             :         zend_long *p, val;
     105             : #ifndef ZTS
     106       23963 :         char *base = (char *) mh_arg2;
     107             : #else
     108             :         char *base;
     109             : 
     110             :         base = (char *) ts_resource(*((int *) mh_arg2));
     111             : #endif
     112             : 
     113       23963 :         p = (zend_long *) (base+(size_t) mh_arg1);
     114             : 
     115       23963 :         val = zend_atol(ZSTR_VAL(new_value), (int)ZSTR_LEN(new_value));
     116             : 
     117       23985 :         if (stage != ZEND_INI_STAGE_STARTUP &&
     118             :             stage != ZEND_INI_STAGE_SHUTDOWN &&
     119          13 :             *p != val &&
     120           9 :             (*p < 0 || val < 0)) {
     121           3 :                 zend_error(E_WARNING, "zend.assertions may be completely enabled or disabled only in php.ini");
     122           3 :                 return FAILURE;
     123             :         }
     124             : 
     125       23960 :         *p = val;
     126       23960 :         return SUCCESS;
     127             : }
     128             : /* }}} */
     129             : 
     130             : ZEND_INI_BEGIN()
     131             :         ZEND_INI_ENTRY("error_reporting",                             NULL,           ZEND_INI_ALL,           OnUpdateErrorReporting)
     132             :         STD_ZEND_INI_ENTRY("zend.assertions",                         "1",    ZEND_INI_ALL,       OnUpdateAssertions,           assertions,   zend_executor_globals,  executor_globals)
     133             :         STD_ZEND_INI_BOOLEAN("zend.enable_gc",                                "1",  ZEND_INI_ALL,           OnUpdateGCEnabled,      gc_enabled,     zend_gc_globals,        gc_globals)
     134             :         STD_ZEND_INI_BOOLEAN("zend.multibyte", "0", ZEND_INI_PERDIR, OnUpdateBool, multibyte,      zend_compiler_globals, compiler_globals)
     135             :         ZEND_INI_ENTRY("zend.script_encoding",                        NULL,           ZEND_INI_ALL,           OnUpdateScriptEncoding)
     136             :         STD_ZEND_INI_BOOLEAN("zend.detect_unicode",                   "1",  ZEND_INI_ALL,           OnUpdateBool, detect_unicode, zend_compiler_globals, compiler_globals)
     137             : #ifdef ZEND_SIGNALS
     138             :         STD_ZEND_INI_BOOLEAN("zend.signal_check", "0", ZEND_INI_SYSTEM, OnUpdateBool, check, zend_signal_globals_t, zend_signal_globals)
     139             : #endif
     140             : ZEND_INI_END()
     141             : 
     142             : 
     143             : #ifdef ZTS
     144             : ZEND_API int compiler_globals_id;
     145             : ZEND_API int executor_globals_id;
     146             : static HashTable *global_function_table = NULL;
     147             : static HashTable *global_class_table = NULL;
     148             : static HashTable *global_constants_table = NULL;
     149             : static HashTable *global_auto_globals_table = NULL;
     150             : static HashTable *global_persistent_list = NULL;
     151             : ZEND_TSRMLS_CACHE_DEFINE()
     152             : #endif
     153             : 
     154             : ZEND_API zend_utility_values zend_uv;
     155             : 
     156             : /* version information */
     157             : static char *zend_version_info;
     158             : static uint zend_version_info_length;
     159             : #define ZEND_CORE_VERSION_INFO  "Zend Engine v" ZEND_VERSION ", Copyright (c) 1998-2016 Zend Technologies\n"
     160             : #define PRINT_ZVAL_INDENT 4
     161             : 
     162             : static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent);
     163             : 
     164        1426 : static void print_hash(smart_str *buf, HashTable *ht, int indent, zend_bool is_object) /* {{{ */
     165             : {
     166             :         zval *tmp;
     167             :         zend_string *string_key;
     168             :         zend_ulong num_key;
     169             :         int i;
     170             : 
     171        6730 :         for (i = 0; i < indent; i++) {
     172             :                 smart_str_appendc(buf, ' ');
     173             :         }
     174             :         smart_str_appends(buf, "(\n");
     175        1426 :         indent += PRINT_ZVAL_INDENT;
     176       21292 :         ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
     177       47370 :                 for (i = 0; i < indent; i++) {
     178             :                         smart_str_appendc(buf, ' ');
     179             :                 }
     180             :                 smart_str_appendc(buf, '[');
     181        6506 :                 if (string_key) {
     182        4498 :                         if (is_object) {
     183             :                                 const char *prop_name, *class_name;
     184             :                                 size_t prop_len;
     185         787 :                                 int mangled = zend_unmangle_property_name_ex(string_key, &class_name, &prop_name, &prop_len);
     186             : 
     187         787 :                                 smart_str_appendl(buf, prop_name, prop_len);
     188         787 :                                 if (class_name && mangled == SUCCESS) {
     189         219 :                                         if (class_name[0] == '*') {
     190             :                                                 smart_str_appends(buf, ":protected");
     191             :                                         } else {
     192             :                                                 smart_str_appends(buf, ":");
     193         114 :                                                 smart_str_appends(buf, class_name);
     194             :                                                 smart_str_appends(buf, ":private");
     195             :                                         }
     196             :                                 }
     197             :                         } else {
     198             :                                 smart_str_append(buf, string_key);
     199             :                         }
     200             :                 } else {
     201        2008 :                         smart_str_append_long(buf, num_key);
     202             :                 }
     203             :                 smart_str_appends(buf, "] => ");
     204        6506 :                 zend_print_zval_r_to_buf(buf, tmp, indent+PRINT_ZVAL_INDENT);
     205             :                 smart_str_appends(buf, "\n");
     206             :         } ZEND_HASH_FOREACH_END();
     207        1426 :         indent -= PRINT_ZVAL_INDENT;
     208        6730 :         for (i = 0; i < indent; i++) {
     209             :                 smart_str_appendc(buf, ' ');
     210             :         }
     211             :         smart_str_appends(buf, ")\n");
     212        1426 : }
     213             : /* }}} */
     214             : 
     215          20 : static void print_flat_hash(HashTable *ht) /* {{{ */
     216             : {
     217             :         zval *tmp;
     218             :         zend_string *string_key;
     219             :         zend_ulong num_key;
     220          20 :         int i = 0;
     221             : 
     222         428 :         ZEND_HASH_FOREACH_KEY_VAL_IND(ht, num_key, string_key, tmp) {
     223         136 :                 if (i++ > 0) {
     224         126 :                         ZEND_PUTS(",");
     225             :                 }
     226         136 :                 ZEND_PUTS("[");
     227         136 :                 if (string_key) {
     228         131 :                         ZEND_WRITE(ZSTR_VAL(string_key), ZSTR_LEN(string_key));
     229             :                 } else {
     230           5 :                         zend_printf(ZEND_ULONG_FMT, num_key);
     231             :                 }
     232         136 :                 ZEND_PUTS("] => ");
     233         136 :                 zend_print_flat_zval_r(tmp);
     234             :         } ZEND_HASH_FOREACH_END();
     235          20 : }
     236             : /* }}} */
     237             : 
     238     1510551 : ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
     239             : {
     240     1510551 :         if (Z_TYPE_P(expr) == IS_STRING) {
     241           1 :                 return 0;
     242             :         } else {
     243     1510550 :                 ZVAL_STR(expr_copy, _zval_get_string_func(expr));
     244     1510550 :                 return 1;
     245             :         }
     246             : }
     247             : /* }}} */
     248             : 
     249        1584 : ZEND_API size_t zend_print_zval(zval *expr, int indent) /* {{{ */
     250             : {
     251        1584 :         zend_string *str = zval_get_string(expr);
     252        1584 :         size_t len = ZSTR_LEN(str);
     253             : 
     254        1584 :         if (len != 0) {
     255        1577 :                 zend_write(ZSTR_VAL(str), len);
     256             :         }
     257             : 
     258             :         zend_string_release(str);
     259        1584 :         return len;
     260             : }
     261             : /* }}} */
     262             : 
     263         204 : ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
     264             : {
     265         204 :         switch (Z_TYPE_P(expr)) {
     266             :                 case IS_ARRAY:
     267          18 :                         ZEND_PUTS("Array (");
     268          54 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
     269          36 :                             ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
     270           0 :                                 ZEND_PUTS(" *RECURSION*");
     271           0 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     272           0 :                                 return;
     273             :                         }
     274          18 :                         print_flat_hash(Z_ARRVAL_P(expr));
     275          18 :                         ZEND_PUTS(")");
     276          18 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
     277          18 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     278             :                         }
     279          18 :                         break;
     280             :                 case IS_OBJECT:
     281             :                 {
     282           2 :                         HashTable *properties = NULL;
     283           2 :                         zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
     284           2 :                         zend_printf("%s Object (", ZSTR_VAL(class_name));
     285             :                         zend_string_release(class_name);
     286             : 
     287           2 :                         if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
     288           0 :                                 ZEND_PUTS(" *RECURSION*");
     289           0 :                                 return;
     290             :                         }
     291             : 
     292           2 :                         if (Z_OBJ_HANDLER_P(expr, get_properties)) {
     293           2 :                                 properties = Z_OBJPROP_P(expr);
     294             :                         }
     295           2 :                         if (properties) {
     296           2 :                                 Z_OBJ_INC_APPLY_COUNT_P(expr);
     297           2 :                                 print_flat_hash(properties);
     298           2 :                                 Z_OBJ_DEC_APPLY_COUNT_P(expr);
     299             :                         }
     300           2 :                         ZEND_PUTS(")");
     301           2 :                         break;
     302             :                 }
     303             :                 case IS_REFERENCE:
     304           1 :                         zend_print_flat_zval_r(Z_REFVAL_P(expr));
     305           1 :                         break;
     306             :                 default:
     307         183 :                         zend_print_variable(expr);
     308             :                         break;
     309             :         }
     310             : }
     311             : /* }}} */
     312             : 
     313        7813 : static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /* {{{ */
     314             : {
     315        7813 :         ZVAL_DEREF(expr);
     316        7813 :         switch (Z_TYPE_P(expr)) {
     317             :                 case IS_ARRAY:
     318             :                         smart_str_appends(buf, "Array\n");
     319        3348 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr)) &&
     320        2232 :                             ++Z_ARRVAL_P(expr)->u.v.nApplyCount>1) {
     321             :                                 smart_str_appends(buf, " *RECURSION*");
     322           0 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     323           0 :                                 return;
     324             :                         }
     325        1116 :                         print_hash(buf, Z_ARRVAL_P(expr), indent, 0);
     326        1116 :                         if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(expr))) {
     327        1116 :                                 Z_ARRVAL_P(expr)->u.v.nApplyCount--;
     328             :                         }
     329        1116 :                         break;
     330             :                 case IS_OBJECT:
     331             :                         {
     332             :                                 HashTable *properties;
     333             :                                 int is_temp;
     334             : 
     335         325 :                                 zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
     336         325 :                                 smart_str_appends(buf, ZSTR_VAL(class_name));
     337             :                                 zend_string_release(class_name);
     338             : 
     339             :                                 smart_str_appends(buf, " Object\n");
     340         325 :                                 if (Z_OBJ_APPLY_COUNT_P(expr) > 0) {
     341             :                                         smart_str_appends(buf, " *RECURSION*");
     342          15 :                                         return;
     343             :                                 }
     344         310 :                                 if ((properties = Z_OBJDEBUG_P(expr, is_temp)) == NULL) {
     345           0 :                                         break;
     346             :                                 }
     347             : 
     348         310 :                                 Z_OBJ_INC_APPLY_COUNT_P(expr);
     349         310 :                                 print_hash(buf, properties, indent, 1);
     350         310 :                                 Z_OBJ_DEC_APPLY_COUNT_P(expr);
     351             : 
     352         310 :                                 if (is_temp) {
     353          47 :                                         zend_hash_destroy(properties);
     354          47 :                                         FREE_HASHTABLE(properties);
     355             :                                 }
     356         310 :                                 break;
     357             :                         }
     358             :                 case IS_LONG:
     359        1368 :                         smart_str_append_long(buf, Z_LVAL_P(expr));
     360        1368 :                         break;
     361             :                 case IS_REFERENCE:
     362           0 :                         zend_print_zval_r_to_buf(buf, Z_REFVAL_P(expr), indent);
     363           0 :                         break;
     364             :                 default:
     365             :                         {
     366        5004 :                                 zend_string *str = zval_get_string(expr);
     367             :                                 smart_str_append(buf, str);
     368             :                                 zend_string_release(str);
     369             :                         }
     370             :                         break;
     371             :         }
     372             : }
     373             : /* }}} */
     374             : 
     375        1307 : ZEND_API zend_string *zend_print_zval_r_to_str(zval *expr, int indent) /* {{{ */
     376             : {
     377        1307 :         smart_str buf = {0};
     378        1307 :         zend_print_zval_r_to_buf(&buf, expr, indent);
     379             :         smart_str_0(&buf);
     380        1307 :         return buf.s;
     381             : }
     382             : /* }}} */
     383             : 
     384        1125 : ZEND_API void zend_print_zval_r(zval *expr, int indent) /* {{{ */
     385             : {
     386        1125 :         zend_string *str = zend_print_zval_r_to_str(expr, indent);
     387        1125 :         zend_write(ZSTR_VAL(str), ZSTR_LEN(str));
     388             :         zend_string_release(str);
     389        1125 : }
     390             : /* }}} */
     391             : 
     392           0 : static FILE *zend_fopen_wrapper(const char *filename, zend_string **opened_path) /* {{{ */
     393             : {
     394           0 :         if (opened_path) {
     395           0 :                 *opened_path = zend_string_init(filename, strlen(filename), 0);
     396             :         }
     397           0 :         return fopen(filename, "rb");
     398             : }
     399             : /* }}} */
     400             : 
     401             : #ifdef ZTS
     402             : static zend_bool short_tags_default      = 1;
     403             : static uint32_t compiler_options_default = ZEND_COMPILE_DEFAULT;
     404             : #else
     405             : # define short_tags_default                     1
     406             : # define compiler_options_default       ZEND_COMPILE_DEFAULT
     407             : #endif
     408             : 
     409       23950 : static void zend_set_default_compile_time_values(void) /* {{{ */
     410             : {
     411             :         /* default compile-time values */
     412       23950 :         CG(short_tags) = short_tags_default;
     413       23950 :         CG(compiler_options) = compiler_options_default;
     414       23950 : }
     415             : /* }}} */
     416             : 
     417             : #ifdef ZEND_WIN32
     418             : static void zend_get_windows_version_info(OSVERSIONINFOEX *osvi) /* {{{ */
     419             : {
     420             :         ZeroMemory(osvi, sizeof(OSVERSIONINFOEX));
     421             :         osvi->dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
     422             :         if(!GetVersionEx((OSVERSIONINFO *) osvi)) {
     423             :                 ZEND_ASSERT(0); /* Should not happen as sizeof is used. */
     424             :         }
     425             : }
     426             : /* }}} */
     427             : #endif
     428             : 
     429       23950 : static void zend_init_exception_op(void) /* {{{ */
     430             : {
     431       23950 :         memset(EG(exception_op), 0, sizeof(EG(exception_op)));
     432       23950 :         EG(exception_op)[0].opcode = ZEND_HANDLE_EXCEPTION;
     433       23950 :         EG(exception_op)[0].op1_type = IS_UNUSED;
     434       23950 :         EG(exception_op)[0].op2_type = IS_UNUSED;
     435       23950 :         EG(exception_op)[0].result_type = IS_UNUSED;
     436       23950 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op));
     437       23950 :         EG(exception_op)[1].opcode = ZEND_HANDLE_EXCEPTION;
     438       23950 :         EG(exception_op)[1].op1_type = IS_UNUSED;
     439       23950 :         EG(exception_op)[1].op2_type = IS_UNUSED;
     440       23950 :         EG(exception_op)[1].result_type = IS_UNUSED;
     441       23950 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+1);
     442       23950 :         EG(exception_op)[2].opcode = ZEND_HANDLE_EXCEPTION;
     443       23950 :         EG(exception_op)[2].op1_type = IS_UNUSED;
     444       23950 :         EG(exception_op)[2].op2_type = IS_UNUSED;
     445       23950 :         EG(exception_op)[2].result_type = IS_UNUSED;
     446       23950 :         ZEND_VM_SET_OPCODE_HANDLER(EG(exception_op)+2);
     447       23950 : }
     448             : /* }}} */
     449             : 
     450       23950 : static void zend_init_call_trampoline_op(void) /* {{{ */
     451             : {
     452       23950 :         memset(&EG(call_trampoline_op), 0, sizeof(EG(call_trampoline_op)));
     453       23950 :         EG(call_trampoline_op).opcode = ZEND_CALL_TRAMPOLINE;
     454       23950 :         EG(call_trampoline_op).op1_type = IS_UNUSED;
     455       23950 :         EG(call_trampoline_op).op2_type = IS_UNUSED;
     456       23950 :         EG(call_trampoline_op).result_type = IS_UNUSED;
     457       23950 :         ZEND_VM_SET_OPCODE_HANDLER(&EG(call_trampoline_op));
     458       23950 : }
     459             : /* }}} */
     460             : 
     461      215721 : static void auto_global_dtor(zval *zv) /* {{{ */
     462             : {
     463      215721 :         free(Z_PTR_P(zv));
     464      215721 : }
     465             : /* }}} */
     466             : 
     467             : #ifdef ZTS
     468             : static void function_copy_ctor(zval *zv) /* {{{ */
     469             : {
     470             :         zend_function *old_func = Z_FUNC_P(zv);
     471             :         Z_FUNC_P(zv) = pemalloc(sizeof(zend_internal_function), 1);
     472             :         memcpy(Z_FUNC_P(zv), old_func, sizeof(zend_internal_function));
     473             :         function_add_ref(Z_FUNC_P(zv));
     474             : }
     475             : /* }}} */
     476             : 
     477             : static void auto_global_copy_ctor(zval *zv) /* {{{ */
     478             : {
     479             :         zend_auto_global *old_ag = (zend_auto_global *) Z_PTR_P(zv);
     480             :         zend_auto_global *new_ag = pemalloc(sizeof(zend_auto_global), 1);
     481             : 
     482             :         new_ag->name = old_ag->name;
     483             :         new_ag->auto_global_callback = old_ag->auto_global_callback;
     484             :         new_ag->jit = old_ag->jit;
     485             : 
     486             :         Z_PTR_P(zv) = new_ag;
     487             : }
     488             : /* }}} */
     489             : 
     490             : static void compiler_globals_ctor(zend_compiler_globals *compiler_globals) /* {{{ */
     491             : {
     492             :         compiler_globals->compiled_filename = NULL;
     493             : 
     494             :         compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
     495             :         zend_hash_init_ex(compiler_globals->function_table, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
     496             :         zend_hash_copy(compiler_globals->function_table, global_function_table, function_copy_ctor);
     497             : 
     498             :         compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
     499             :         zend_hash_init_ex(compiler_globals->class_table, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
     500             :         zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref);
     501             : 
     502             :         zend_set_default_compile_time_values();
     503             : 
     504             :         compiler_globals->auto_globals = (HashTable *) malloc(sizeof(HashTable));
     505             :         zend_hash_init_ex(compiler_globals->auto_globals, 8, NULL, auto_global_dtor, 1, 0);
     506             :         zend_hash_copy(compiler_globals->auto_globals, global_auto_globals_table, auto_global_copy_ctor);
     507             : 
     508             :         compiler_globals->last_static_member = zend_hash_num_elements(compiler_globals->class_table);
     509             :         if (compiler_globals->last_static_member) {
     510             :                 compiler_globals->static_members_table = calloc(compiler_globals->last_static_member, sizeof(zval*));
     511             :         } else {
     512             :                 compiler_globals->static_members_table = NULL;
     513             :         }
     514             :         compiler_globals->script_encoding_list = NULL;
     515             : 
     516             :         compiler_globals->empty_string = zend_zts_interned_string_init("", sizeof("")-1);
     517             : 
     518             :         memset(compiler_globals->one_char_string, 0, sizeof(compiler_globals->one_char_string));
     519             : 
     520             :         zend_known_interned_strings_init(&compiler_globals->known_strings, &compiler_globals->known_strings_count);
     521             : }
     522             : /* }}} */
     523             : 
     524             : static void compiler_globals_dtor(zend_compiler_globals *compiler_globals) /* {{{ */
     525             : {
     526             :         if (compiler_globals->function_table != GLOBAL_FUNCTION_TABLE) {
     527             :                 zend_hash_destroy(compiler_globals->function_table);
     528             :                 free(compiler_globals->function_table);
     529             :         }
     530             :         if (compiler_globals->class_table != GLOBAL_CLASS_TABLE) {
     531             :                 zend_hash_destroy(compiler_globals->class_table);
     532             :                 free(compiler_globals->class_table);
     533             :         }
     534             :         if (compiler_globals->auto_globals != GLOBAL_AUTO_GLOBALS_TABLE) {
     535             :                 zend_hash_destroy(compiler_globals->auto_globals);
     536             :                 free(compiler_globals->auto_globals);
     537             :         }
     538             :         if (compiler_globals->static_members_table) {
     539             :                 free(compiler_globals->static_members_table);
     540             :         }
     541             :         if (compiler_globals->script_encoding_list) {
     542             :                 pefree((char*)compiler_globals->script_encoding_list, 1);
     543             :         }
     544             :         compiler_globals->last_static_member = 0;
     545             : 
     546             :         zend_zts_interned_string_free(&compiler_globals->empty_string);
     547             : 
     548             :         compiler_globals->known_strings = NULL;
     549             :         compiler_globals->known_strings_count = 0;
     550             : }
     551             : /* }}} */
     552             : 
     553             : static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{{ */
     554             : {
     555             :         ZEND_TSRMLS_CACHE_UPDATE();
     556             : 
     557             :         zend_startup_constants();
     558             :         zend_copy_constants(EG(zend_constants), GLOBAL_CONSTANTS_TABLE);
     559             :         zend_init_rsrc_plist();
     560             :         zend_init_exception_op();
     561             :         zend_init_call_trampoline_op();
     562             :         memset(&executor_globals->trampoline, 0, sizeof(zend_op_array));
     563             :         executor_globals->lambda_count = 0;
     564             :         ZVAL_UNDEF(&executor_globals->user_error_handler);
     565             :         ZVAL_UNDEF(&executor_globals->user_exception_handler);
     566             :         executor_globals->in_autoload = NULL;
     567             :         executor_globals->current_execute_data = NULL;
     568             :         executor_globals->current_module = NULL;
     569             :         executor_globals->exit_status = 0;
     570             : #if XPFPA_HAVE_CW
     571             :         executor_globals->saved_fpu_cw = 0;
     572             : #endif
     573             :         executor_globals->saved_fpu_cw_ptr = NULL;
     574             :         executor_globals->active = 0;
     575             :         executor_globals->bailout = NULL;
     576             :         executor_globals->error_handling  = EH_NORMAL;
     577             :         executor_globals->exception_class = NULL;
     578             :         executor_globals->exception = NULL;
     579             :         executor_globals->objects_store.object_buckets = NULL;
     580             : #ifdef ZEND_WIN32
     581             :         zend_get_windows_version_info(&executor_globals->windows_version_info);
     582             : #endif
     583             : }
     584             : /* }}} */
     585             : 
     586             : static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{{ */
     587             : {
     588             :         zend_ini_dtor(executor_globals->ini_directives);
     589             : 
     590             :         if (&executor_globals->persistent_list != global_persistent_list) {
     591             :                 zend_destroy_rsrc_list(&executor_globals->persistent_list);
     592             :         }
     593             :         if (executor_globals->zend_constants != GLOBAL_CONSTANTS_TABLE) {
     594             :                 zend_hash_destroy(executor_globals->zend_constants);
     595             :                 free(executor_globals->zend_constants);
     596             :         }
     597             : }
     598             : /* }}} */
     599             : 
     600             : static void zend_new_thread_end_handler(THREAD_T thread_id) /* {{{ */
     601             : {
     602             :         if (zend_copy_ini_directives() == SUCCESS) {
     603             :                 zend_ini_refresh_caches(ZEND_INI_STAGE_STARTUP);
     604             :         }
     605             : }
     606             : /* }}} */
     607             : #endif
     608             : 
     609             : #if defined(__FreeBSD__) || defined(__DragonFly__)
     610             : /* FreeBSD and DragonFly floating point precision fix */
     611             : #include <floatingpoint.h>
     612             : #endif
     613             : 
     614       23950 : static void ini_scanner_globals_ctor(zend_ini_scanner_globals *scanner_globals_p) /* {{{ */
     615             : {
     616       23950 :         memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
     617       23950 : }
     618             : /* }}} */
     619             : 
     620       23950 : static void php_scanner_globals_ctor(zend_php_scanner_globals *scanner_globals_p) /* {{{ */
     621             : {
     622       23950 :         memset(scanner_globals_p, 0, sizeof(*scanner_globals_p));
     623       23950 : }
     624             : /* }}} */
     625             : 
     626             : void zend_init_opcodes_handlers(void);
     627             : 
     628     1702098 : static void module_destructor_zval(zval *zv) /* {{{ */
     629             : {
     630     1702098 :         zend_module_entry *module = (zend_module_entry*)Z_PTR_P(zv);
     631             : 
     632     1702098 :         module_destructor(module);
     633     1702098 :         free(module);
     634     1702098 : }
     635             : /* }}} */
     636             : 
     637         199 : static zend_bool php_auto_globals_create_globals(zend_string *name) /* {{{ */
     638             : {
     639             :         zval globals;
     640             : 
     641         199 :         ZVAL_ARR(&globals, &EG(symbol_table));
     642         199 :         Z_TYPE_INFO_P(&globals) = IS_ARRAY;
     643         199 :         ZVAL_NEW_REF(&globals, &globals);
     644         199 :         zend_hash_update(&EG(symbol_table), name, &globals);
     645         199 :         return 0;
     646             : }
     647             : /* }}} */
     648             : 
     649       23950 : int zend_startup(zend_utility_functions *utility_functions, char **extensions) /* {{{ */
     650             : {
     651             : #ifdef ZTS
     652             :         zend_compiler_globals *compiler_globals;
     653             :         zend_executor_globals *executor_globals;
     654             :         extern ZEND_API ts_rsrc_id ini_scanner_globals_id;
     655             :         extern ZEND_API ts_rsrc_id language_scanner_globals_id;
     656             :         ZEND_TSRMLS_CACHE_UPDATE();
     657             : #else
     658             :         extern zend_ini_scanner_globals ini_scanner_globals;
     659             :         extern zend_php_scanner_globals language_scanner_globals;
     660             : #endif
     661             : 
     662       23950 :         start_memory_manager();
     663             : 
     664       23950 :         virtual_cwd_startup(); /* Could use shutdown to free the main cwd but it would just slow it down for CGI */
     665             : 
     666             : #if defined(__FreeBSD__) || defined(__DragonFly__)
     667             :         /* FreeBSD and DragonFly floating point precision fix */
     668             :         fpsetmask(0);
     669             : #endif
     670             : 
     671       23950 :         zend_startup_strtod();
     672       23950 :         zend_startup_extensions_mechanism();
     673             : 
     674             :         /* Set up utility functions and values */
     675       23950 :         zend_error_cb = utility_functions->error_function;
     676       23950 :         zend_printf = utility_functions->printf_function;
     677       23950 :         zend_write = (zend_write_func_t) utility_functions->write_function;
     678       23950 :         zend_fopen = utility_functions->fopen_function;
     679       23950 :         if (!zend_fopen) {
     680           0 :                 zend_fopen = zend_fopen_wrapper;
     681             :         }
     682       23950 :         zend_stream_open_function = utility_functions->stream_open_function;
     683       23950 :         zend_message_dispatcher_p = utility_functions->message_handler;
     684       23950 :         zend_get_configuration_directive_p = utility_functions->get_configuration_directive;
     685       23950 :         zend_ticks_function = utility_functions->ticks_function;
     686       23950 :         zend_on_timeout = utility_functions->on_timeout;
     687       23950 :         zend_vspprintf = utility_functions->vspprintf_function;
     688       23950 :         zend_vstrpprintf = utility_functions->vstrpprintf_function;
     689       23950 :         zend_getenv = utility_functions->getenv_function;
     690       23950 :         zend_resolve_path = utility_functions->resolve_path_function;
     691             : 
     692       23950 :         zend_interrupt_function = NULL;
     693             : 
     694             : #if HAVE_DTRACE
     695             : /* build with dtrace support */
     696             :         zend_compile_file = dtrace_compile_file;
     697             :         zend_execute_ex = dtrace_execute_ex;
     698             :         zend_execute_internal = dtrace_execute_internal;
     699             : #else
     700       23950 :         zend_compile_file = compile_file;
     701       23950 :         zend_execute_ex = execute_ex;
     702       23950 :         zend_execute_internal = NULL;
     703             : #endif /* HAVE_SYS_SDT_H */
     704       23950 :         zend_compile_string = compile_string;
     705       23950 :         zend_throw_exception_hook = NULL;
     706             : 
     707             :         /* Set up the default garbage collection implementation. */
     708       23950 :         gc_collect_cycles = zend_gc_collect_cycles;
     709             : 
     710       23950 :         zend_init_opcodes_handlers();
     711             : 
     712             :         /* set up version */
     713       23950 :         zend_version_info = strdup(ZEND_CORE_VERSION_INFO);
     714       23950 :         zend_version_info_length = sizeof(ZEND_CORE_VERSION_INFO) - 1;
     715             : 
     716       23950 :         GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
     717       23950 :         GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     718       23950 :         GLOBAL_AUTO_GLOBALS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     719       23950 :         GLOBAL_CONSTANTS_TABLE = (HashTable *) malloc(sizeof(HashTable));
     720             : 
     721       23950 :         zend_hash_init_ex(GLOBAL_FUNCTION_TABLE, 1024, NULL, ZEND_FUNCTION_DTOR, 1, 0);
     722       23950 :         zend_hash_init_ex(GLOBAL_CLASS_TABLE, 64, NULL, ZEND_CLASS_DTOR, 1, 0);
     723       23950 :         zend_hash_init_ex(GLOBAL_AUTO_GLOBALS_TABLE, 8, NULL, auto_global_dtor, 1, 0);
     724       23950 :         zend_hash_init_ex(GLOBAL_CONSTANTS_TABLE, 128, NULL, ZEND_CONSTANT_DTOR, 1, 0);
     725             : 
     726       23950 :         zend_hash_init_ex(&module_registry, 32, NULL, module_destructor_zval, 1, 0);
     727       23950 :         zend_init_rsrc_list_dtors();
     728             : 
     729             : #ifdef ZTS
     730             :         ts_allocate_id(&compiler_globals_id, sizeof(zend_compiler_globals), (ts_allocate_ctor) compiler_globals_ctor, (ts_allocate_dtor) compiler_globals_dtor);
     731             :         ts_allocate_id(&executor_globals_id, sizeof(zend_executor_globals), (ts_allocate_ctor) executor_globals_ctor, (ts_allocate_dtor) executor_globals_dtor);
     732             :         ts_allocate_id(&language_scanner_globals_id, sizeof(zend_php_scanner_globals), (ts_allocate_ctor) php_scanner_globals_ctor, NULL);
     733             :         ts_allocate_id(&ini_scanner_globals_id, sizeof(zend_ini_scanner_globals), (ts_allocate_ctor) ini_scanner_globals_ctor, NULL);
     734             :         compiler_globals = ts_resource(compiler_globals_id);
     735             :         executor_globals = ts_resource(executor_globals_id);
     736             : 
     737             :         compiler_globals_dtor(compiler_globals);
     738             :         compiler_globals->in_compilation = 0;
     739             :         compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
     740             :         compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
     741             : 
     742             :         *compiler_globals->function_table = *GLOBAL_FUNCTION_TABLE;
     743             :         *compiler_globals->class_table = *GLOBAL_CLASS_TABLE;
     744             :         compiler_globals->auto_globals = GLOBAL_AUTO_GLOBALS_TABLE;
     745             : 
     746             :         zend_hash_destroy(executor_globals->zend_constants);
     747             :         *executor_globals->zend_constants = *GLOBAL_CONSTANTS_TABLE;
     748             : #else
     749       23950 :         ini_scanner_globals_ctor(&ini_scanner_globals);
     750       23950 :         php_scanner_globals_ctor(&language_scanner_globals);
     751       23950 :         zend_set_default_compile_time_values();
     752             : #ifdef ZEND_WIN32
     753             :         zend_get_windows_version_info(&EG(windows_version_info));
     754             : #endif
     755             : #endif
     756       23950 :         EG(error_reporting) = E_ALL & ~E_NOTICE;
     757             : 
     758       23950 :         zend_interned_strings_init();
     759       23950 :         zend_startup_builtin_functions();
     760       23950 :         zend_register_standard_constants();
     761       23950 :         zend_register_auto_global(zend_string_init("GLOBALS", sizeof("GLOBALS") - 1, 1), 1, php_auto_globals_create_globals);
     762             : 
     763             : #ifndef ZTS
     764       23950 :         zend_init_rsrc_plist();
     765       23950 :         zend_init_exception_op();
     766       23950 :         zend_init_call_trampoline_op();
     767             : #endif
     768             : 
     769       23950 :         zend_ini_startup();
     770             : 
     771             : #ifdef ZEND_WIN32
     772             :         /* Uses INI settings, so needs to be run after it. */
     773             :         php_win32_cp_setup();
     774             : #endif
     775             : 
     776             : #ifdef ZTS
     777             :         tsrm_set_new_thread_end_handler(zend_new_thread_end_handler);
     778             : #endif
     779             : 
     780       23950 :         return SUCCESS;
     781             : }
     782             : /* }}} */
     783             : 
     784       23950 : void zend_register_standard_ini_entries(void) /* {{{ */
     785             : {
     786       23950 :         int module_number = 0;
     787             : 
     788       23950 :         REGISTER_INI_ENTRIES();
     789       23950 : }
     790             : /* }}} */
     791             : 
     792             : /* Unlink the global (r/o) copies of the class, function and constant tables,
     793             :  * and use a fresh r/w copy for the startup thread
     794             :  */
     795       23950 : void zend_post_startup(void) /* {{{ */
     796             : {
     797             : #ifdef ZTS
     798             :         zend_encoding **script_encoding_list;
     799             : 
     800             :         zend_compiler_globals *compiler_globals = ts_resource(compiler_globals_id);
     801             :         zend_executor_globals *executor_globals = ts_resource(executor_globals_id);
     802             : 
     803             :         *GLOBAL_FUNCTION_TABLE = *compiler_globals->function_table;
     804             :         *GLOBAL_CLASS_TABLE = *compiler_globals->class_table;
     805             :         *GLOBAL_CONSTANTS_TABLE = *executor_globals->zend_constants;
     806             : 
     807             :         short_tags_default = CG(short_tags);
     808             :         compiler_options_default = CG(compiler_options);
     809             : 
     810             :         zend_destroy_rsrc_list(&EG(persistent_list));
     811             :         free(compiler_globals->function_table);
     812             :         free(compiler_globals->class_table);
     813             :         if ((script_encoding_list = (zend_encoding **)compiler_globals->script_encoding_list)) {
     814             :                 compiler_globals_ctor(compiler_globals);
     815             :                 compiler_globals->script_encoding_list = (const zend_encoding **)script_encoding_list;
     816             :         } else {
     817             :                 compiler_globals_ctor(compiler_globals);
     818             :         }
     819             :         free(EG(zend_constants));
     820             : 
     821             :         virtual_cwd_deactivate();
     822             : 
     823             :         executor_globals_ctor(executor_globals);
     824             :         global_persistent_list = &EG(persistent_list);
     825             :         zend_copy_ini_directives();
     826             : #else
     827       23950 :         virtual_cwd_deactivate();
     828             : #endif
     829       23950 : }
     830             : /* }}} */
     831             : 
     832       23969 : void zend_shutdown(void) /* {{{ */
     833             : {
     834       23969 :         zend_destroy_rsrc_list(&EG(persistent_list));
     835       23969 :         if (EG(active))
     836             :         {
     837             :                 /*
     838             :                  * The order of destruction is important here.
     839             :                  * See bugs #65463 and 66036.
     840             :                  */
     841             :                 zend_function *func;
     842             :                 zend_class_entry *ce;
     843             : 
     844           0 :                 ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_FUNCTION_TABLE, func) {
     845           0 :                         if (func->type == ZEND_USER_FUNCTION) {
     846           0 :                                 zend_cleanup_op_array_data((zend_op_array *) func);
     847             :                         }
     848             :                 } ZEND_HASH_FOREACH_END();
     849           0 :                 ZEND_HASH_REVERSE_FOREACH_PTR(GLOBAL_CLASS_TABLE, ce) {
     850           0 :                         if (ce->type == ZEND_USER_CLASS) {
     851           0 :                                 zend_cleanup_user_class_data(ce);
     852             :                         } else {
     853           0 :                                 break;
     854             :                         }
     855             :                 } ZEND_HASH_FOREACH_END();
     856           0 :                 zend_cleanup_internal_classes();
     857           0 :                 zend_hash_reverse_apply(GLOBAL_FUNCTION_TABLE, (apply_func_t) clean_non_persistent_function_full);
     858           0 :                 zend_hash_reverse_apply(GLOBAL_CLASS_TABLE, (apply_func_t) clean_non_persistent_class_full);
     859             :         }
     860       23969 :         zend_destroy_modules();
     861             : 
     862       23969 :         virtual_cwd_deactivate();
     863       23969 :         virtual_cwd_shutdown();
     864             : 
     865       23969 :         zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
     866       23969 :         zend_hash_destroy(GLOBAL_CLASS_TABLE);
     867             : 
     868       23969 :         zend_hash_destroy(GLOBAL_AUTO_GLOBALS_TABLE);
     869       23969 :         free(GLOBAL_AUTO_GLOBALS_TABLE);
     870             : 
     871       23969 :         zend_shutdown_extensions();
     872       23969 :         free(zend_version_info);
     873             : 
     874       23969 :         free(GLOBAL_FUNCTION_TABLE);
     875       23969 :         free(GLOBAL_CLASS_TABLE);
     876             : 
     877       23969 :         zend_hash_destroy(GLOBAL_CONSTANTS_TABLE);
     878       23969 :         free(GLOBAL_CONSTANTS_TABLE);
     879       23969 :         zend_shutdown_strtod();
     880             : 
     881             : #ifdef ZTS
     882             :         GLOBAL_FUNCTION_TABLE = NULL;
     883             :         GLOBAL_CLASS_TABLE = NULL;
     884             :         GLOBAL_AUTO_GLOBALS_TABLE = NULL;
     885             :         GLOBAL_CONSTANTS_TABLE = NULL;
     886             : #endif
     887       23969 :         zend_destroy_rsrc_list_dtors();
     888             : 
     889       23969 :         zend_interned_strings_dtor();
     890       23969 : }
     891             : /* }}} */
     892             : 
     893       23950 : void zend_set_utility_values(zend_utility_values *utility_values) /* {{{ */
     894             : {
     895       23950 :         zend_uv = *utility_values;
     896       23950 :         zend_uv.import_use_extension_length = (uint)strlen(zend_uv.import_use_extension);
     897       23950 : }
     898             : /* }}} */
     899             : 
     900             : /* this should be compatible with the standard zenderror */
     901          65 : ZEND_COLD void zenderror(const char *error) /* {{{ */
     902             : {
     903          65 :         if (EG(exception)) {
     904             :                 /* An exception was thrown in the lexer, don't throw another in the parser. */
     905          14 :                 return;
     906             :         }
     907             : 
     908          51 :         zend_throw_exception(zend_ce_parse_error, error, 0);
     909             : }
     910             : /* }}} */
     911             : 
     912             : BEGIN_EXTERN_C()
     913        2890 : ZEND_API ZEND_COLD void _zend_bailout(char *filename, uint lineno) /* {{{ */
     914             : {
     915             : 
     916        2890 :         if (!EG(bailout)) {
     917           0 :                 zend_output_debug_string(1, "%s(%d) : Bailed out without a bailout address!", filename, lineno);
     918           0 :                 exit(-1);
     919             :         }
     920        2890 :         CG(unclean_shutdown) = 1;
     921        2890 :         CG(active_class_entry) = NULL;
     922        2890 :         CG(in_compilation) = 0;
     923        2890 :         EG(current_execute_data) = NULL;
     924        2890 :         LONGJMP(*EG(bailout), FAILURE);
     925             : }
     926             : /* }}} */
     927             : END_EXTERN_C()
     928             : 
     929       23773 : ZEND_API void zend_append_version_info(const zend_extension *extension) /* {{{ */
     930             : {
     931             :         char *new_info;
     932             :         uint new_info_length;
     933             : 
     934       95092 :         new_info_length = (uint)(sizeof("    with  v, , by \n")
     935       23773 :                                                 + strlen(extension->name)
     936       23773 :                                                 + strlen(extension->version)
     937       23773 :                                                 + strlen(extension->copyright)
     938       23773 :                                                 + strlen(extension->author));
     939             : 
     940       23773 :         new_info = (char *) malloc(new_info_length + 1);
     941             : 
     942       23773 :         snprintf(new_info, new_info_length, "    with %s v%s, %s, by %s\n", extension->name, extension->version, extension->copyright, extension->author);
     943             : 
     944       23773 :         zend_version_info = (char *) realloc(zend_version_info, zend_version_info_length+new_info_length + 1);
     945       23773 :         strncat(zend_version_info, new_info, new_info_length);
     946       23773 :         zend_version_info_length += new_info_length;
     947       23773 :         free(new_info);
     948       23773 : }
     949             : /* }}} */
     950             : 
     951         162 : ZEND_API char *get_zend_version(void) /* {{{ */
     952             : {
     953         162 :         return zend_version_info;
     954             : }
     955             : /* }}} */
     956             : 
     957       23904 : ZEND_API void zend_activate(void) /* {{{ */
     958             : {
     959             : #ifdef ZTS
     960             :         virtual_cwd_activate();
     961             : #endif
     962       23904 :         gc_reset();
     963       23904 :         init_compiler();
     964       23904 :         init_executor();
     965       23904 :         startup_scanner();
     966       23904 : }
     967             : /* }}} */
     968             : 
     969       23925 : void zend_call_destructors(void) /* {{{ */
     970             : {
     971       23925 :         zend_try {
     972       23925 :                 shutdown_destructors();
     973       23925 :         } zend_end_try();
     974       23925 : }
     975             : /* }}} */
     976             : 
     977       23925 : ZEND_API void zend_deactivate(void) /* {{{ */
     978             : {
     979             :         /* we're no longer executing anything */
     980       23925 :         EG(current_execute_data) = NULL;
     981             : 
     982       23925 :         zend_try {
     983       23925 :                 shutdown_scanner();
     984       23925 :         } zend_end_try();
     985             : 
     986             :         /* shutdown_executor() takes care of its own bailout handling */
     987       23925 :         shutdown_executor();
     988             : 
     989       23925 :         zend_try {
     990       23925 :                 zend_ini_deactivate();
     991       23925 :         } zend_end_try();
     992             : 
     993       23925 :         zend_try {
     994       23925 :                 shutdown_compiler();
     995       23925 :         } zend_end_try();
     996             : 
     997       23925 :         zend_destroy_rsrc_list(&EG(regular_list));
     998             : 
     999             : #if GC_BENCH
    1000             :         fprintf(stderr, "GC Statistics\n");
    1001             :         fprintf(stderr, "-------------\n");
    1002             :         fprintf(stderr, "Runs:               %d\n", GC_G(gc_runs));
    1003             :         fprintf(stderr, "Collected:          %d\n", GC_G(collected));
    1004             :         fprintf(stderr, "Root buffer length: %d\n", GC_G(root_buf_length));
    1005             :         fprintf(stderr, "Root buffer peak:   %d\n\n", GC_G(root_buf_peak));
    1006             :         fprintf(stderr, "      Possible            Remove from  Marked\n");
    1007             :         fprintf(stderr, "        Root    Buffered     buffer     grey\n");
    1008             :         fprintf(stderr, "      --------  --------  -----------  ------\n");
    1009             :         fprintf(stderr, "ZVAL  %8d  %8d  %9d  %8d\n", GC_G(zval_possible_root), GC_G(zval_buffered), GC_G(zval_remove_from_buffer), GC_G(zval_marked_grey));
    1010             : #endif
    1011       23925 : }
    1012             : /* }}} */
    1013             : 
    1014             : BEGIN_EXTERN_C()
    1015          34 : ZEND_API void zend_message_dispatcher(zend_long message, const void *data) /* {{{ */
    1016             : {
    1017          34 :         if (zend_message_dispatcher_p) {
    1018          34 :                 zend_message_dispatcher_p(message, data);
    1019             :         }
    1020          31 : }
    1021             : /* }}} */
    1022             : END_EXTERN_C()
    1023             : 
    1024     6607992 : ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
    1025             : {
    1026     6607992 :         if (zend_get_configuration_directive_p) {
    1027     6607992 :                 return zend_get_configuration_directive_p(name);
    1028             :         } else {
    1029           0 :                 return NULL;
    1030             :         }
    1031             : }
    1032             : /* }}} */
    1033             : 
    1034             : #define SAVE_STACK(stack) do { \
    1035             :                 if (CG(stack).top) { \
    1036             :                         memcpy(&stack, &CG(stack), sizeof(zend_stack)); \
    1037             :                         CG(stack).top = CG(stack).max = 0; \
    1038             :                         CG(stack).elements = NULL; \
    1039             :                 } else { \
    1040             :                         stack.top = 0; \
    1041             :                 } \
    1042             :         } while (0)
    1043             : 
    1044             : #define RESTORE_STACK(stack) do { \
    1045             :                 if (stack.top) { \
    1046             :                         zend_stack_destroy(&CG(stack)); \
    1047             :                         memcpy(&CG(stack), &stack, sizeof(zend_stack)); \
    1048             :                 } \
    1049             :         } while (0)
    1050             : 
    1051             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1052      433357 : ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) /* {{{ */
    1053             : #else
    1054             : static ZEND_COLD void zend_error_va_list(int type, const char *format, va_list args)
    1055             : #endif
    1056             : {
    1057             :         char *str;
    1058             :         int len;
    1059             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1060             :         va_list args;
    1061             : #endif
    1062             :         va_list usr_copy;
    1063             :         zval params[5];
    1064             :         zval retval;
    1065             :         const char *error_filename;
    1066      433357 :         uint error_lineno = 0;
    1067             :         zval orig_user_error_handler;
    1068             :         zend_bool in_compilation;
    1069             :         zend_class_entry *saved_class_entry;
    1070             :         zend_stack loop_var_stack;
    1071             :         zend_stack delayed_oplines_stack;
    1072             :         zend_array *symbol_table;
    1073             : 
    1074             :         /* Report about uncaught exception in case of fatal errors */
    1075      433357 :         if (EG(exception)) {
    1076             :                 zend_execute_data *ex;
    1077             :                 const zend_op *opline;
    1078             : 
    1079          48 :                 switch (type) {
    1080             :                         case E_CORE_ERROR:
    1081             :                         case E_ERROR:
    1082             :                         case E_RECOVERABLE_ERROR:
    1083             :                         case E_PARSE:
    1084             :                         case E_COMPILE_ERROR:
    1085             :                         case E_USER_ERROR:
    1086           3 :                                 ex = EG(current_execute_data);
    1087           3 :                                 opline = NULL;
    1088           8 :                                 while (ex && (!ex->func || !ZEND_USER_CODE(ex->func->type))) {
    1089           2 :                                         ex = ex->prev_execute_data;
    1090             :                                 }
    1091           4 :                                 if (ex && ex->opline->opcode == ZEND_HANDLE_EXCEPTION &&
    1092           1 :                                     EG(opline_before_exception)) {
    1093           1 :                                         opline = EG(opline_before_exception);
    1094             :                                 }
    1095           3 :                                 zend_exception_error(EG(exception), E_WARNING);
    1096           3 :                                 EG(exception) = NULL;
    1097           3 :                                 if (opline) {
    1098           1 :                                         ex->opline = opline;
    1099             :                                 }
    1100             :                                 break;
    1101             :                         default:
    1102             :                                 break;
    1103             :                 }
    1104             :         }
    1105             : 
    1106             :         /* Obtain relevant filename and lineno */
    1107      433357 :         switch (type) {
    1108             :                 case E_CORE_ERROR:
    1109             :                 case E_CORE_WARNING:
    1110           5 :                         error_filename = NULL;
    1111           5 :                         error_lineno = 0;
    1112           5 :                         break;
    1113             :                 case E_PARSE:
    1114             :                 case E_COMPILE_ERROR:
    1115             :                 case E_COMPILE_WARNING:
    1116             :                 case E_ERROR:
    1117             :                 case E_NOTICE:
    1118             :                 case E_STRICT:
    1119             :                 case E_DEPRECATED:
    1120             :                 case E_WARNING:
    1121             :                 case E_USER_ERROR:
    1122             :                 case E_USER_WARNING:
    1123             :                 case E_USER_NOTICE:
    1124             :                 case E_USER_DEPRECATED:
    1125             :                 case E_RECOVERABLE_ERROR:
    1126      433352 :                         if (zend_is_compiling()) {
    1127         408 :                                 error_filename = ZSTR_VAL(zend_get_compiled_filename());
    1128         408 :                                 error_lineno = zend_get_compiled_lineno();
    1129      432944 :                         } else if (zend_is_executing()) {
    1130      432906 :                                 error_filename = zend_get_executed_filename();
    1131      432906 :                                 if (error_filename[0] == '[') { /* [no active file] */
    1132           3 :                                         error_filename = NULL;
    1133           3 :                                         error_lineno = 0;
    1134             :                                 } else {
    1135      432903 :                                         error_lineno = zend_get_executed_lineno();
    1136             :                                 }
    1137             :                         } else {
    1138          38 :                                 error_filename = NULL;
    1139          38 :                                 error_lineno = 0;
    1140             :                         }
    1141      433352 :                         break;
    1142             :                 default:
    1143           0 :                         error_filename = NULL;
    1144           0 :                         error_lineno = 0;
    1145             :                         break;
    1146             :         }
    1147      433357 :         if (!error_filename) {
    1148          46 :                 error_filename = "Unknown";
    1149             :         }
    1150             : 
    1151             : #ifdef HAVE_DTRACE
    1152             :         if (DTRACE_ERROR_ENABLED()) {
    1153             :                 char *dtrace_error_buffer;
    1154             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1155             :                 va_start(args, format);
    1156             : #endif
    1157             :                 zend_vspprintf(&dtrace_error_buffer, 0, format, args);
    1158             :                 DTRACE_ERROR(dtrace_error_buffer, (char *)error_filename, error_lineno);
    1159             :                 efree(dtrace_error_buffer);
    1160             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1161             :                 va_end(args);
    1162             : #endif
    1163             :         }
    1164             : #endif /* HAVE_DTRACE */
    1165             : 
    1166             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1167      433357 :         va_start(args, format);
    1168             : #endif
    1169             : 
    1170             :         /* if we don't have a user defined error handler */
    1171      868696 :         if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF
    1172        2477 :                 || !(EG(user_error_handler_error_reporting) & type)
    1173        2453 :                 || EG(error_handling) != EH_NORMAL) {
    1174      430904 :                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1175        2453 :         } else switch (type) {
    1176             :                 case E_ERROR:
    1177             :                 case E_PARSE:
    1178             :                 case E_CORE_ERROR:
    1179             :                 case E_CORE_WARNING:
    1180             :                 case E_COMPILE_ERROR:
    1181             :                 case E_COMPILE_WARNING:
    1182             :                         /* The error may not be safe to handle in user-space */
    1183           6 :                         zend_error_cb(type, error_filename, error_lineno, format, args);
    1184           0 :                         break;
    1185             :                 default:
    1186             :                         /* Handle the error in user space */
    1187             : /* va_copy() is __va_copy() in old gcc versions.
    1188             :  * According to the autoconf manual, using
    1189             :  * memcpy(&dst, &src, sizeof(va_list))
    1190             :  * gives maximum portability. */
    1191             : #ifndef va_copy
    1192             : # ifdef __va_copy
    1193             : #  define va_copy(dest, src)    __va_copy((dest), (src))
    1194             : # else
    1195             : #  define va_copy(dest, src)    memcpy(&(dest), &(src), sizeof(va_list))
    1196             : # endif
    1197             : #endif
    1198        2447 :                         va_copy(usr_copy, args);
    1199        2447 :                         len = (int)zend_vspprintf(&str, 0, format, usr_copy);
    1200        4894 :                         ZVAL_NEW_STR(&params[1], zend_string_init(str, len, 0));
    1201        2447 :                         efree(str);
    1202             : #ifdef va_copy
    1203        2447 :                         va_end(usr_copy);
    1204             : #endif
    1205             : 
    1206        2447 :                         ZVAL_LONG(&params[0], type);
    1207             : 
    1208        2447 :                         if (error_filename) {
    1209        4894 :                                 ZVAL_STRING(&params[2], error_filename);
    1210             :                         } else {
    1211           0 :                                 ZVAL_NULL(&params[2]);
    1212             :                         }
    1213             : 
    1214        2447 :                         ZVAL_LONG(&params[3], error_lineno);
    1215             : 
    1216        2447 :                         symbol_table = zend_rebuild_symbol_table();
    1217             : 
    1218             :                         /* during shutdown the symbol table table can be still null */
    1219        2447 :                         if (!symbol_table) {
    1220           0 :                                 ZVAL_NULL(&params[4]);
    1221             :                         } else {
    1222        2447 :                                 ZVAL_ARR(&params[4], zend_array_dup(symbol_table));
    1223             :                         }
    1224             : 
    1225        2447 :                         ZVAL_COPY_VALUE(&orig_user_error_handler, &EG(user_error_handler));
    1226        2447 :                         ZVAL_UNDEF(&EG(user_error_handler));
    1227             : 
    1228             :                         /* User error handler may include() additinal PHP files.
    1229             :                          * If an error was generated during comilation PHP will compile
    1230             :                          * such scripts recursivly, but some CG() variables may be
    1231             :                          * inconsistent. */
    1232             : 
    1233        2447 :                         in_compilation = CG(in_compilation);
    1234        2447 :                         if (in_compilation) {
    1235           5 :                                 saved_class_entry = CG(active_class_entry);
    1236           5 :                                 CG(active_class_entry) = NULL;
    1237           5 :                                 SAVE_STACK(loop_var_stack);
    1238           5 :                                 SAVE_STACK(delayed_oplines_stack);
    1239           5 :                                 CG(in_compilation) = 0;
    1240             :                         }
    1241             : 
    1242        2447 :                         if (call_user_function_ex(CG(function_table), NULL, &orig_user_error_handler, &retval, 5, params, 1, NULL) == SUCCESS) {
    1243        2446 :                                 if (Z_TYPE(retval) != IS_UNDEF) {
    1244        2408 :                                         if (Z_TYPE(retval) == IS_FALSE) {
    1245           4 :                                                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1246             :                                         }
    1247        2408 :                                         zval_ptr_dtor(&retval);
    1248             :                                 }
    1249           1 :                         } else if (!EG(exception)) {
    1250             :                                 /* The user error handler failed, use built-in error handler */
    1251           0 :                                 zend_error_cb(type, error_filename, error_lineno, format, args);
    1252             :                         }
    1253             : 
    1254        2447 :                         if (in_compilation) {
    1255           5 :                                 CG(active_class_entry) = saved_class_entry;
    1256           5 :                                 RESTORE_STACK(loop_var_stack);
    1257           5 :                                 RESTORE_STACK(delayed_oplines_stack);
    1258           5 :                                 CG(in_compilation) = 1;
    1259             :                         }
    1260             : 
    1261        2447 :                         zval_ptr_dtor(&params[4]);
    1262        2447 :                         zval_ptr_dtor(&params[3]);
    1263        2447 :                         zval_ptr_dtor(&params[2]);
    1264        2447 :                         zval_ptr_dtor(&params[1]);
    1265        2447 :                         zval_ptr_dtor(&params[0]);
    1266             : 
    1267        2447 :                         if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF) {
    1268        2447 :                                 ZVAL_COPY_VALUE(&EG(user_error_handler), &orig_user_error_handler);
    1269             :                         } else {
    1270           0 :                                 zval_ptr_dtor(&orig_user_error_handler);
    1271             :                         }
    1272             :                         break;
    1273             :         }
    1274             : 
    1275             : #if !defined(HAVE_NORETURN) || defined(HAVE_NORETURN_ALIAS)
    1276      432856 :         va_end(args);
    1277             : #endif
    1278             : 
    1279      432856 :         if (type == E_PARSE) {
    1280             :                 /* eval() errors do not affect exit_status */
    1281           0 :                 if (!(EG(current_execute_data) &&
    1282           0 :                         EG(current_execute_data)->func &&
    1283           0 :                         ZEND_USER_CODE(EG(current_execute_data)->func->type) &&
    1284           0 :                         EG(current_execute_data)->opline->opcode == ZEND_INCLUDE_OR_EVAL &&
    1285           0 :                         EG(current_execute_data)->opline->extended_value == ZEND_EVAL)) {
    1286           0 :                         EG(exit_status) = 255;
    1287             :                 }
    1288             :         }
    1289      432856 : }
    1290             : /* }}} */
    1291             : 
    1292             : #ifdef HAVE_NORETURN
    1293             : # ifdef HAVE_NORETURN_ALIAS
    1294             : ZEND_COLD void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
    1295             : # else
    1296             : ZEND_API ZEND_COLD void zend_error(int type, const char *format, ...) /* {{{ */
    1297             : {
    1298             :         va_list va;
    1299             : 
    1300             :         va_start(va, format);
    1301             :         zend_error_va_list(type, format, va);
    1302             :         va_end(va);
    1303             : }
    1304             : 
    1305             : ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
    1306             : {
    1307             :         va_list va;
    1308             : 
    1309             :         va_start(va, format);
    1310             :         zend_error_va_list(type, format, va);
    1311             :         va_end(va);
    1312             : }
    1313             : /* }}} */
    1314             : # endif
    1315             : #endif
    1316             : 
    1317         470 : ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format, ...) /* {{{ */
    1318             : {
    1319             :         va_list va;
    1320         470 :         char *message = NULL;
    1321             :         
    1322         470 :         if (exception_ce) {
    1323          68 :                 if (!instanceof_function(exception_ce, zend_ce_error)) {
    1324           0 :                         zend_error(E_NOTICE, "Error exceptions must be derived from Error");
    1325           0 :                         exception_ce = zend_ce_error;
    1326             :                 }
    1327             :         } else {
    1328         402 :                 exception_ce = zend_ce_error;
    1329             :         }
    1330             : 
    1331         470 :         va_start(va, format);
    1332         470 :         zend_vspprintf(&message, 0, format, va);
    1333             : 
    1334             :         //TODO: we can't convert compile-time errors to exceptions yet???
    1335         937 :         if (EG(current_execute_data) && !CG(in_compilation)) {
    1336         467 :                 zend_throw_exception(exception_ce, message, 0);
    1337             :         } else {
    1338           3 :                 zend_error(E_ERROR, "%s", message);
    1339             :         }
    1340             : 
    1341         467 :         efree(message);
    1342         467 :         va_end(va);
    1343         467 : }
    1344             : /* }}} */
    1345             : 
    1346         410 : ZEND_API ZEND_COLD void zend_type_error(const char *format, ...) /* {{{ */
    1347             : {
    1348             :         va_list va;
    1349         410 :         char *message = NULL;
    1350             : 
    1351         410 :         va_start(va, format);
    1352         410 :         zend_vspprintf(&message, 0, format, va);
    1353         410 :         zend_throw_exception(zend_ce_type_error, message, 0);
    1354         410 :         efree(message);
    1355         410 :         va_end(va);
    1356         410 : } /* }}} */
    1357             : 
    1358        8342 : ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
    1359             : {
    1360             :         va_list va;
    1361        8342 :         char *message = NULL;
    1362             : 
    1363        8342 :         va_start(va, format);
    1364        8342 :         zend_vspprintf(&message, 0, format, va);
    1365        8342 :         if (throw_exception) {
    1366          75 :                 zend_throw_exception(zend_ce_type_error, message, 0);
    1367             :         } else {
    1368        8267 :                 zend_error(E_WARNING, "%s", message);
    1369             :         }
    1370        8342 :         efree(message);
    1371             : 
    1372        8342 :         va_end(va);
    1373        8342 : } /* }}} */
    1374             : 
    1375        2780 : ZEND_API ZEND_COLD void zend_internal_argument_count_error(zend_bool throw_exception, const char *format, ...) /* {{{ */
    1376             : {
    1377             :         va_list va;
    1378        2780 :         char *message = NULL;
    1379             : 
    1380        2780 :         va_start(va, format);
    1381        2780 :         zend_vspprintf(&message, 0, format, va);
    1382        2780 :         if (throw_exception) {
    1383          40 :                 zend_throw_exception(zend_ce_argument_count_error, message, 0);
    1384             :         } else {
    1385        2740 :                 zend_error(E_WARNING, "%s", message);
    1386             :         }
    1387        2780 :         efree(message);
    1388             : 
    1389        2780 :         va_end(va);
    1390        2780 : } /* }}} */
    1391             : 
    1392           0 : ZEND_API ZEND_COLD void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */
    1393             : {
    1394             : #if ZEND_DEBUG
    1395             :         va_list args;
    1396             : 
    1397             :         va_start(args, format);
    1398             : #       ifdef ZEND_WIN32
    1399             :         {
    1400             :                 char output_buf[1024];
    1401             : 
    1402             :                 vsnprintf(output_buf, 1024, format, args);
    1403             :                 OutputDebugString(output_buf);
    1404             :                 OutputDebugString("\n");
    1405             :                 if (trigger_break && IsDebuggerPresent()) {
    1406             :                         DebugBreak();
    1407             :                 }
    1408             :         }
    1409             : #       else
    1410             :         vfprintf(stderr, format, args);
    1411             :         fprintf(stderr, "\n");
    1412             : #       endif
    1413             :         va_end(args);
    1414             : #endif
    1415           0 : }
    1416             : /* }}} */
    1417             : 
    1418       21882 : ZEND_API void zend_try_exception_handler() /* {{{ */
    1419             : {
    1420       21882 :         if (EG(exception)) {
    1421         544 :                 if (Z_TYPE(EG(user_exception_handler)) != IS_UNDEF) {
    1422             :                         zval orig_user_exception_handler;
    1423             :                         zval params[1], retval2;
    1424             :                         zend_object *old_exception;
    1425          10 :                         old_exception = EG(exception);
    1426          10 :                         EG(exception) = NULL;
    1427          10 :                         ZVAL_OBJ(&params[0], old_exception);
    1428          10 :                         ZVAL_COPY_VALUE(&orig_user_exception_handler, &EG(user_exception_handler));
    1429             : 
    1430          10 :                         if (call_user_function_ex(CG(function_table), NULL, &orig_user_exception_handler, &retval2, 1, params, 1, NULL) == SUCCESS) {
    1431           8 :                                 zval_ptr_dtor(&retval2);
    1432           8 :                                 if (EG(exception)) {
    1433           0 :                                         OBJ_RELEASE(EG(exception));
    1434           0 :                                         EG(exception) = NULL;
    1435             :                                 }
    1436             :                                 OBJ_RELEASE(old_exception);
    1437             :                         } else {
    1438           0 :                                 EG(exception) = old_exception;
    1439             :                         }
    1440             :                 }
    1441             :         }
    1442       21880 : } /* }}} */
    1443             : 
    1444       23782 : ZEND_API int zend_execute_scripts(int type, zval *retval, int file_count, ...) /* {{{ */
    1445             : {
    1446             :         va_list files;
    1447             :         int i;
    1448             :         zend_file_handle *file_handle;
    1449             :         zend_op_array *op_array;
    1450             : 
    1451       23782 :         va_start(files, file_count);
    1452       90215 :         for (i = 0; i < file_count; i++) {
    1453       68885 :                 file_handle = va_arg(files, zend_file_handle *);
    1454       68885 :                 if (!file_handle) {
    1455       45103 :                         continue;
    1456             :                 }
    1457             : 
    1458       23782 :                 op_array = zend_compile_file(file_handle, type);
    1459       23491 :                 if (file_handle->opened_path) {
    1460       23488 :                         zend_hash_add_empty_element(&EG(included_files), file_handle->opened_path);
    1461             :                 }
    1462       23491 :                 zend_destroy_file_handle(file_handle);
    1463       23491 :                 if (op_array) {
    1464       23455 :                         zend_execute(op_array, retval);
    1465       21857 :                         zend_exception_restore();
    1466       21857 :                         zend_try_exception_handler();
    1467       21855 :                         if (EG(exception)) {
    1468         532 :                                 zend_exception_error(EG(exception), E_ERROR);
    1469             :                         }
    1470       21330 :                         destroy_op_array(op_array);
    1471       21330 :                         efree_size(op_array, sizeof(zend_op_array));
    1472          36 :                 } else if (type==ZEND_REQUIRE) {
    1473          36 :                         va_end(files);
    1474          36 :                         return FAILURE;
    1475             :                 }
    1476             :         }
    1477       21330 :         va_end(files);
    1478             : 
    1479       21330 :         return SUCCESS;
    1480             : }
    1481             : /* }}} */
    1482             : 
    1483             : #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d) : %s"
    1484             : 
    1485        1186 : ZEND_API char *zend_make_compiled_string_description(const char *name) /* {{{ */
    1486             : {
    1487             :         const char *cur_filename;
    1488             :         int cur_lineno;
    1489             :         char *compiled_string_description;
    1490             : 
    1491        1186 :         if (zend_is_compiling()) {
    1492           0 :                 cur_filename = ZSTR_VAL(zend_get_compiled_filename());
    1493           0 :                 cur_lineno = zend_get_compiled_lineno();
    1494        1186 :         } else if (zend_is_executing()) {
    1495        1186 :                 cur_filename = zend_get_executed_filename();
    1496        1186 :                 cur_lineno = zend_get_executed_lineno();
    1497             :         } else {
    1498           0 :                 cur_filename = "Unknown";
    1499           0 :                 cur_lineno = 0;
    1500             :         }
    1501             : 
    1502        1186 :         zend_spprintf(&compiled_string_description, 0, COMPILED_STRING_DESCRIPTION_FORMAT, cur_filename, cur_lineno, name);
    1503        1186 :         return compiled_string_description;
    1504             : }
    1505             : /* }}} */
    1506             : 
    1507       23774 : void free_estring(char **str_p) /* {{{ */
    1508             : {
    1509       23774 :         efree(*str_p);
    1510       23774 : }
    1511             : /* }}} */
    1512             : 
    1513             : /*
    1514             :  * Local variables:
    1515             :  * tab-width: 4
    1516             :  * c-basic-offset: 4
    1517             :  * indent-tabs-mode: t
    1518             :  * End:
    1519             :  */

Generated by: LCOV version 1.10

Generated at Tue, 27 Sep 2016 10:25:53 +0000 (3 days ago)

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