@@ -447,9 +447,8 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
447
447
argnum = php_sprintf_getnumber (& format , & format_len );
448
448
449
449
if (argnum <= 0 ) {
450
- zend_string_efree (result );
451
450
zend_value_error ("Argument number must be greater than zero" );
452
- return NULL ;
451
+ goto fail ;
453
452
}
454
453
argnum -- ;
455
454
format ++ ; /* skip the '$' */
@@ -477,8 +476,7 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
477
476
padding = * format ;
478
477
} else {
479
478
zend_value_error ("Missing padding character" );
480
- zend_string_efree (result );
481
- return NULL ;
479
+ goto fail ;
482
480
}
483
481
} else {
484
482
PRINTF_DEBUG (("sprintf: end of modifiers\n" ));
@@ -494,9 +492,8 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
494
492
if (isdigit ((int )* format )) {
495
493
PRINTF_DEBUG (("sprintf: getting width\n" ));
496
494
if ((width = php_sprintf_getnumber (& format , & format_len )) < 0 ) {
497
- efree (result );
498
495
zend_value_error ("Width must be greater than zero and less than %d" , INT_MAX );
499
- return NULL ;
496
+ goto fail ;
500
497
}
501
498
adjusting |= ADJ_WIDTH ;
502
499
} else {
@@ -511,9 +508,8 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
511
508
PRINTF_DEBUG (("sprintf: getting precision\n" ));
512
509
if (isdigit ((int )* format )) {
513
510
if ((precision = php_sprintf_getnumber (& format , & format_len )) < 0 ) {
514
- efree (result );
515
511
zend_value_error ("Precision must be greater than zero and less than %d" , INT_MAX );
516
- return NULL ;
512
+ goto fail ;
517
513
}
518
514
adjusting |= ADJ_PRECISION ;
519
515
expprec = 1 ;
@@ -633,20 +629,23 @@ php_formatted_print(char *format, size_t format_len, zval *args, int argc, int n
633
629
}
634
630
635
631
if (max_missing_argnum >= 0 ) {
636
- efree (result );
637
632
if (nb_additional_parameters == -1 ) {
638
633
zend_value_error ("The arguments array must contain %d items, %d given" , max_missing_argnum + 1 , argc );
639
634
} else {
640
635
zend_argument_count_error ("%d parameters are required, %d given" , max_missing_argnum + nb_additional_parameters + 1 , argc + nb_additional_parameters );
641
636
}
642
- return NULL ;
637
+ goto fail ;
643
638
}
644
639
645
640
exit :
646
641
/* possibly, we have to make sure we have room for the terminating null? */
647
642
ZSTR_VAL (result )[outpos ]= 0 ;
648
643
ZSTR_LEN (result ) = outpos ;
649
644
return result ;
645
+
646
+ fail :
647
+ zend_string_efree (result );
648
+ return NULL ;
650
649
}
651
650
/* }}} */
652
651
0 commit comments