@@ -304,16 +304,19 @@ static void ReleaseCharSet(CharSet *cset)
304304 *
305305 *----------------------------------------------------------------------
306306*/
307- static int ValidateFormat (char * format , int numVars , uint32_t * totalSubs )
307+ static int ValidateFormat (char * format , uint32_t numVars , uint32_t * totalSubs )
308308{
309309#define STATIC_LIST_SIZE 16
310- int value , i , flags ;
310+ int flags ;
311311 bool gotXpg = false;
312312 bool gotSequential = false;
313313 char * end , * ch = NULL ;
314- int staticAssign [STATIC_LIST_SIZE ];
315- int * nassign = staticAssign ;
316- int objIndex , xpgSize , nspace = STATIC_LIST_SIZE ;
314+ uint32_t staticAssign [STATIC_LIST_SIZE ];
315+ uint32_t * nassign = staticAssign ;
316+ uint32_t objIndex = 0 ;
317+ uint32_t xpgSize = 0 ;
318+ uint32_t nspace = STATIC_LIST_SIZE ;
319+ zend_ulong value ;
317320
318321 bool assignToVariables = numVars ;
319322 /*
@@ -322,15 +325,13 @@ static int ValidateFormat(char *format, int numVars, uint32_t *totalSubs)
322325 * a variable is multiply assigned or left unassigned.
323326 */
324327 if (numVars > nspace ) {
325- nassign = ( int * ) safe_emalloc (sizeof (int ), numVars , 0 );
328+ nassign = safe_emalloc (sizeof (uint32_t ), numVars , 0 );
326329 nspace = numVars ;
327330 }
328331 for (i = 0 ; i < nspace ; i ++ ) {
329332 nassign [i ] = 0 ;
330333 }
331334
332- xpgSize = objIndex = 0 ;
333-
334335 while (* format != '\0' ) {
335336 ch = format ++ ;
336337 flags = 0 ;
@@ -490,21 +491,21 @@ static int ValidateFormat(char *format, int numVars, uint32_t *totalSubs)
490491 * make sure that we grow to a large enough size. xpgSize is
491492 * guaranteed to be at least one larger than objIndex.
492493 */
493- value = nspace ;
494+ uint32_t value = nspace ;
494495 if (xpgSize ) {
495496 nspace = xpgSize ;
496497 } else {
497498 nspace += STATIC_LIST_SIZE ;
498499 }
499500 if (nassign == staticAssign ) {
500501 nassign = (void * )safe_emalloc (nspace , sizeof (int ), 0 );
501- for (i = 0 ; i < STATIC_LIST_SIZE ; ++ i ) {
502+ for (uint32_t i = 0 ; i < STATIC_LIST_SIZE ; ++ i ) {
502503 nassign [i ] = staticAssign [i ];
503504 }
504505 } else {
505506 nassign = (void * )erealloc ((void * )nassign , nspace * sizeof (int ));
506507 }
507- for (i = value ; i < nspace ; i ++ ) {
508+ for (uint32_t i = value ; i < nspace ; i ++ ) {
508509 nassign [i ] = 0 ;
509510 }
510511 }
@@ -526,7 +527,7 @@ static int ValidateFormat(char *format, int numVars, uint32_t *totalSubs)
526527
527528 * totalSubs = numVars ;
528529
529- for (i = 0 ; i < numVars ; i ++ ) {
530+ for (uint32_t i = 0 ; i < numVars ; i ++ ) {
530531 if (nassign [i ] > 1 ) {
531532 zend_value_error ("%s" , "Variable is assigned by multiple \"%n$\" conversion specifiers" );
532533 goto error ;
0 commit comments