@@ -80,8 +80,6 @@ static char *zend_version_info;
8080static uint32_t zend_version_info_length ;
8181#define ZEND_CORE_VERSION_INFO "Zend Engine v" ZEND_VERSION ", Copyright (c) Zend Technologies\n"
8282#define PRINT_ZVAL_INDENT 4
83- #define ZEND_ERR_BUF_SIZE (capacity ) \
84- (XtOffsetOf(struct zend_err_buf, buf) + sizeof(zend_error_info *) * (capacity))
8583
8684/* true multithread-shared globals */
8785ZEND_API zend_class_entry * zend_standard_class_def = NULL ;
@@ -645,12 +643,6 @@ static FILE *zend_fopen_wrapper(zend_string *filename, zend_string **opened_path
645643}
646644/* }}} */
647645
648- static void zend_init_errors_buf (zend_executor_globals * eg )
649- {
650- eg -> errors = pemalloc (ZEND_ERR_BUF_SIZE (2 ), true);
651- eg -> errors -> capacity = 2 ;
652- eg -> errors -> size = 0 ;
653- }
654646
655647#ifdef ZTS
656648static bool short_tags_default = true;
@@ -842,7 +834,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
842834#endif
843835 executor_globals -> flags = EG_FLAGS_INITIAL ;
844836 executor_globals -> record_errors = false;
845- zend_init_errors_buf ( executor_globals );
837+ memset ( & executor_globals -> errors , 0 , sizeof ( executor_globals -> errors ) );
846838 executor_globals -> filename_override = NULL ;
847839 executor_globals -> lineno_override = -1 ;
848840#ifdef ZEND_CHECK_STACK_LIMIT
@@ -877,8 +869,6 @@ static void executor_globals_dtor(zend_executor_globals *executor_globals) /* {{
877869 zend_hash_destroy (executor_globals -> zend_constants );
878870 free (executor_globals -> zend_constants );
879871 }
880-
881- pefree (executor_globals -> errors , true);
882872}
883873/* }}} */
884874
@@ -1075,7 +1065,6 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
10751065 zend_init_rsrc_plist ();
10761066 zend_init_exception_op ();
10771067 zend_init_call_trampoline_op ();
1078- zend_init_errors_buf (& executor_globals );
10791068#endif
10801069
10811070 zend_ini_startup ();
@@ -1158,7 +1147,6 @@ zend_result zend_post_startup(void) /* {{{ */
11581147 free (EG (zend_constants ));
11591148 EG (zend_constants ) = NULL ;
11601149
1161- pefree (executor_globals -> errors , true);
11621150 executor_globals_ctor (executor_globals );
11631151 global_persistent_list = & EG (persistent_list );
11641152 zend_copy_ini_directives ();
@@ -1236,7 +1224,6 @@ void zend_shutdown(void) /* {{{ */
12361224 pefree (CG (internal_run_time_cache ), 1 );
12371225 CG (internal_run_time_cache ) = NULL ;
12381226 }
1239- pefree (EG (errors ), true);
12401227#endif
12411228 zend_map_ptr_static_last = 0 ;
12421229 zend_map_ptr_static_size = 0 ;
@@ -1472,11 +1459,11 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
14721459 }
14731460
14741461 /* Emit any delayed error before handling fatal error */
1475- if ((type & E_FATAL_ERRORS ) && !(type & E_DONT_BAIL ) && EG (errors -> size ) ) {
1476- uint32_t num_errors = EG (errors -> size ) ;
1477- uint32_t cap_errors = EG (errors -> capacity ) ;
1478- zend_error_info * * errors = EG (errors -> buf ) ;
1479- EG (errors -> size ) = 0 ;
1462+ if ((type & E_FATAL_ERRORS ) && !(type & E_DONT_BAIL ) && EG (errors ). size ) {
1463+ uint32_t num_errors = EG (errors ). size ;
1464+ uint32_t cap_errors = EG (errors ). capacity ;
1465+ zend_error_info * * errors = EG (errors ). errors ;
1466+ EG (errors ). size = 0 ;
14801467
14811468 bool orig_record_errors = EG (record_errors );
14821469 EG (record_errors ) = false;
@@ -1490,8 +1477,8 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
14901477
14911478 EG (user_error_handler_error_reporting ) = orig_user_error_handler_error_reporting ;
14921479 EG (record_errors ) = orig_record_errors ;
1493- EG (errors -> size ) = num_errors ;
1494- EG (errors -> capacity ) = cap_errors ;
1480+ EG (errors ). size = num_errors ;
1481+ EG (errors ). capacity = cap_errors ;
14951482 }
14961483
14971484 if (EG (record_errors )) {
@@ -1500,13 +1487,13 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
15001487 info -> lineno = error_lineno ;
15011488 info -> filename = zend_string_copy (error_filename );
15021489 info -> message = zend_string_copy (message );
1503- EG (errors -> size ) ++ ;
1504- if (EG (errors -> size ) >= EG (errors -> capacity ) ) {
1505- uint32_t capacity = EG (errors -> capacity ) + (EG (errors -> capacity ) >> 1 );
1506- EG (errors ) = safe_perealloc (EG (errors ), sizeof (zend_error_info * ), capacity , XtOffsetOf ( struct zend_err_buf , buf ), true );
1507- EG (errors -> capacity ) = capacity ;
1490+ EG (errors ). size ++ ;
1491+ if (EG (errors ). size > EG (errors ). capacity ) {
1492+ uint32_t capacity = EG (errors ). capacity ? EG ( errors ). capacity + (EG (errors ). capacity >> 1 ) : 2 ;
1493+ EG (errors ). errors = erealloc (EG (errors ). errors , sizeof (zend_error_info * ) * capacity );
1494+ EG (errors ). capacity = capacity ;
15081495 }
1509- EG (errors -> buf ) [EG (errors -> size ) - 1 ] = info ;
1496+ EG (errors ). errors [EG (errors ). size - 1 ] = info ;
15101497
15111498 /* Do not process non-fatal recorded error */
15121499 if (!(type & E_FATAL_ERRORS ) || (type & E_DONT_BAIL )) {
@@ -1591,16 +1578,16 @@ ZEND_API ZEND_COLD void zend_error_zstr_at(
15911578 orig_record_errors = EG (record_errors );
15921579 EG (record_errors ) = false;
15931580
1594- orig_num_errors = EG (errors -> size ) ;
1595- orig_cap_errors = EG (errors -> capacity ) ;
1596- EG (errors -> size ) = 0 ;
1581+ orig_num_errors = EG (errors ). size ;
1582+ orig_cap_errors = EG (errors ). capacity ;
1583+ EG (errors ). size = 0 ;
15971584
15981585 res = call_user_function (CG (function_table ), NULL , & orig_user_error_handler , & retval , 4 , params );
15991586
16001587 EG (record_errors ) = orig_record_errors ;
16011588
1602- EG (errors -> capacity ) = orig_cap_errors ;
1603- EG (errors -> size ) = orig_num_errors ;
1589+ EG (errors ). capacity = orig_cap_errors ;
1590+ EG (errors ). size = orig_num_errors ;
16041591
16051592 if (res == SUCCESS ) {
16061593 if (Z_TYPE (retval ) != IS_UNDEF ) {
@@ -1795,7 +1782,7 @@ ZEND_API void zend_begin_record_errors(void)
17951782{
17961783 ZEND_ASSERT (!EG (record_errors ) && "Error recording already enabled" );
17971784 EG (record_errors ) = true;
1798- EG (errors -> size ) = 0 ;
1785+ EG (errors ). size = 0 ;
17991786}
18001787
18011788ZEND_API void zend_emit_recorded_errors_ex (uint32_t num_errors , zend_error_info * * errors )
@@ -1809,22 +1796,22 @@ ZEND_API void zend_emit_recorded_errors_ex(uint32_t num_errors, zend_error_info
18091796ZEND_API void zend_emit_recorded_errors (void )
18101797{
18111798 EG (record_errors ) = false;
1812- zend_emit_recorded_errors_ex (EG (errors -> size ) , EG (errors -> buf ) );
1799+ zend_emit_recorded_errors_ex (EG (errors ). size , EG (errors ). errors );
18131800}
18141801
18151802ZEND_API void zend_free_recorded_errors (void )
18161803{
1817- if (!EG (errors -> size ) ) {
1804+ if (!EG (errors ). size ) {
18181805 return ;
18191806 }
18201807
1821- for (uint32_t i = 0 ; i < EG (errors -> size ) ; i ++ ) {
1822- zend_error_info * info = EG (errors -> buf ) [i ];
1808+ for (uint32_t i = 0 ; i < EG (errors ). size ; i ++ ) {
1809+ zend_error_info * info = EG (errors ). errors [i ];
18231810 zend_string_release (info -> filename );
18241811 zend_string_release (info -> message );
18251812 efree_size (info , sizeof (zend_error_info ));
18261813 }
1827- EG (errors -> size ) = 0 ;
1814+ EG (errors ). size = 0 ;
18281815}
18291816
18301817ZEND_API ZEND_COLD void zend_throw_error (zend_class_entry * exception_ce , const char * format , ...) /* {{{ */
@@ -2032,12 +2019,12 @@ ZEND_API zend_result zend_execute_scripts(int type, zval *retval, int file_count
20322019}
20332020/* }}} */
20342021
2035- #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%u ) : %s"
2022+ #define COMPILED_STRING_DESCRIPTION_FORMAT "%s(%d ) : %s"
20362023
20372024ZEND_API char * zend_make_compiled_string_description (const char * name ) /* {{{ */
20382025{
20392026 const char * cur_filename ;
2040- uint32_t cur_lineno ;
2027+ int cur_lineno ;
20412028 char * compiled_string_description ;
20422029
20432030 if (zend_is_compiling ()) {
0 commit comments