File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1049,8 +1049,15 @@ PHP_FUNCTION(grapheme_levenshtein)
10491049 }
10501050
10511051 zend_long * p1 , * p2 , * tmp ;
1052+ #if SIZEOF_SIZE_T == 8
1053+ /* strlen_2 is an int32_t, so it will not overflow. */
1054+ zend_long * pbuf = safe_emalloc (((size_t ) strlen_2 + 1 ) * 2 , sizeof (zend_long ), 0 );
1055+ p1 = pbuf ;
1056+ p2 = p1 + (strlen_2 + 1 );
1057+ #else
10521058 p1 = safe_emalloc (strlen_2 + 1 , sizeof (zend_long ), 0 );
10531059 p2 = safe_emalloc (strlen_2 + 1 , sizeof (zend_long ), 0 );
1060+ #endif
10541061
10551062 for (i2 = 0 ; i2 <= strlen_2 ; i2 ++ ) {
10561063 p1 [i2 ] = i2 * cost_ins ;
@@ -1098,8 +1105,12 @@ PHP_FUNCTION(grapheme_levenshtein)
10981105 retval = p1 [strlen_2 ];
10991106 RETVAL_LONG (retval );
11001107
1108+ #if SIZEOF_SIZE_T == 8
1109+ efree (pbuf );
1110+ #else
11011111 efree (p2 );
11021112 efree (p1 );
1113+ #endif
11031114
11041115out_collator :
11051116 ucol_close (collator );
You can’t perform that action at this time.
0 commit comments