@@ -529,7 +529,7 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
529
529
}
530
530
/* }}} */
531
531
532
- static void _build_trace_string (smart_str * str , HashTable * ht , uint32_t num ) /* {{{ */
532
+ static void _build_trace_string (smart_str * str , const HashTable * ht , uint32_t num ) /* {{{ */
533
533
{
534
534
zval * file , * tmp ;
535
535
@@ -539,14 +539,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
539
539
540
540
file = zend_hash_find_known_hash (ht , ZSTR_KNOWN (ZEND_STR_FILE ));
541
541
if (file ) {
542
- if (Z_TYPE_P (file ) != IS_STRING ) {
542
+ if (UNEXPECTED ( Z_TYPE_P (file ) != IS_STRING ) ) {
543
543
zend_error (E_WARNING , "File name is not a string" );
544
544
smart_str_appends (str , "[unknown file]: " );
545
545
} else {
546
546
zend_long line = 0 ;
547
547
tmp = zend_hash_find_known_hash (ht , ZSTR_KNOWN (ZEND_STR_LINE ));
548
548
if (tmp ) {
549
- if (Z_TYPE_P (tmp ) == IS_LONG ) {
549
+ if (EXPECTED ( Z_TYPE_P (tmp ) == IS_LONG ) ) {
550
550
line = Z_LVAL_P (tmp );
551
551
} else {
552
552
zend_error (E_WARNING , "Line is not an int" );
@@ -566,7 +566,7 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
566
566
smart_str_appendc (str , '(' );
567
567
tmp = zend_hash_find_known_hash (ht , ZSTR_KNOWN (ZEND_STR_ARGS ));
568
568
if (tmp ) {
569
- if (Z_TYPE_P (tmp ) == IS_ARRAY ) {
569
+ if (EXPECTED ( Z_TYPE_P (tmp ) == IS_ARRAY ) ) {
570
570
size_t last_len = ZSTR_LEN (str -> s );
571
571
zend_string * name ;
572
572
zval * arg ;
@@ -590,14 +590,14 @@ static void _build_trace_string(smart_str *str, HashTable *ht, uint32_t num) /*
590
590
}
591
591
/* }}} */
592
592
593
- ZEND_API zend_string * zend_trace_to_string (HashTable * trace , bool include_main ) {
593
+ ZEND_API zend_string * zend_trace_to_string (const HashTable * trace , bool include_main ) {
594
594
zend_ulong index ;
595
595
zval * frame ;
596
596
uint32_t num = 0 ;
597
597
smart_str str = {0 };
598
598
599
599
ZEND_HASH_FOREACH_NUM_KEY_VAL (trace , index , frame ) {
600
- if (Z_TYPE_P (frame ) != IS_ARRAY ) {
600
+ if (UNEXPECTED ( Z_TYPE_P (frame ) != IS_ARRAY ) ) {
601
601
zend_error (E_WARNING , "Expected array for frame " ZEND_ULONG_FMT , index );
602
602
continue ;
603
603
}
@@ -624,7 +624,7 @@ ZEND_METHOD(Exception, getTraceAsString)
624
624
zval * object = ZEND_THIS ;
625
625
zend_class_entry * base_ce = i_get_exception_base (Z_OBJ_P (object ));
626
626
zval rv ;
627
- zval * trace = zend_read_property_ex (base_ce , Z_OBJ_P (object ), ZSTR_KNOWN (ZEND_STR_TRACE ), 1 , & rv );
627
+ const zval * trace = zend_read_property_ex (base_ce , Z_OBJ_P (object ), ZSTR_KNOWN (ZEND_STR_TRACE ), 1 , & rv );
628
628
if (EG (exception )) {
629
629
RETURN_THROWS ();
630
630
}
@@ -859,14 +859,13 @@ ZEND_API ZEND_COLD zend_object *zend_throw_exception(zend_class_entry *exception
859
859
ZEND_API ZEND_COLD zend_object * zend_throw_exception_ex (zend_class_entry * exception_ce , zend_long code , const char * format , ...) /* {{{ */
860
860
{
861
861
va_list arg ;
862
- char * message ;
863
862
zend_object * obj ;
864
863
865
864
va_start (arg , format );
866
- zend_vspprintf ( & message , 0 , format , arg );
865
+ zend_string * msg_str = zend_vstrpprintf ( 0 , format , arg );
867
866
va_end (arg );
868
- obj = zend_throw_exception (exception_ce , message , code );
869
- efree ( message );
867
+ obj = zend_throw_exception_zstr (exception_ce , msg_str , code );
868
+ zend_string_release ( msg_str );
870
869
return obj ;
871
870
}
872
871
/* }}} */
0 commit comments