@@ -304,7 +304,7 @@ static void ReleaseCharSet(CharSet *cset)
304304 *
305305 *----------------------------------------------------------------------
306306*/
307- static int ValidateFormat (char * format , int numVars , int * totalSubs )
307+ static int ValidateFormat (char * format , int numVars , uint32_t * totalSubs )
308308{
309309#define STATIC_LIST_SIZE 16
310310 int gotXpg , gotSequential , value , i , flags ;
@@ -521,9 +521,9 @@ static int ValidateFormat(char *format, int numVars, int *totalSubs)
521521 numVars = objIndex ;
522522 }
523523 }
524- if ( totalSubs ) {
525- * totalSubs = numVars ;
526- }
524+
525+ * totalSubs = numVars ;
526+
527527 for (i = 0 ; i < numVars ; i ++ ) {
528528 if (nassign [i ] > 1 ) {
529529 zend_value_error ("%s" , "Variable is assigned by multiple \"%n$\" conversion specifiers" );
@@ -575,7 +575,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
575575 uint32_t argCount , zval * args ,
576576 zval * return_value )
577577{
578- int numVars , nconversions , totalVars = -1 ;
578+ int numVars , nconversions ;
579579 int i , result ;
580580 zend_long value ;
581581 zend_ulong objIndex ;
@@ -601,6 +601,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
601601 /*
602602 * Check for errors in the format string.
603603 */
604+ uint32_t totalVars = 0 ;
604605 if (ValidateFormat (format , numVars , & totalVars ) != SCAN_SUCCESS ) {
605606 scan_set_error_return ( assignToVariables , return_value );
606607 return SCAN_ERROR_INVALID_FORMAT ;
@@ -627,7 +628,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
627628 /* allocate an array for return */
628629 array_init (return_value );
629630
630- for (i = 0 ; i < totalVars ; i ++ ) {
631+ for (uint32_t i = 0 ; i < totalVars ; i ++ ) {
631632 ZVAL_NULL (& tmp );
632633 if (add_next_index_zval (return_value , & tmp ) == FAILURE ) {
633634 scan_set_error_return (0 , return_value );
0 commit comments