@@ -10014,14 +10014,16 @@ do_capitalize(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UC
10014
10014
Py_UCS4 c , mapped [3 ];
10015
10015
10016
10016
c = PyUnicode_READ (kind , data , 0 );
10017
- n_res = PyUnicode_ToTitle (c , mapped , 3 );
10017
+ n_res = PyUnicode_ToTitle (c , mapped , Py_ARRAY_LENGTH (mapped ));
10018
+ assert (n_res >= 1 );
10018
10019
for (j = 0 ; j < n_res ; j ++ ) {
10019
10020
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10020
10021
res [k ++ ] = mapped [j ];
10021
10022
}
10022
10023
for (i = 1 ; i < length ; i ++ ) {
10023
10024
c = PyUnicode_READ (kind , data , i );
10024
- n_res = lower_ucs4 (kind , data , length , i , c , mapped , 3 );
10025
+ n_res = lower_ucs4 (kind , data , length , i , c , mapped , Py_ARRAY_LENGTH (mapped ));
10026
+ assert (n_res >= 1 );
10025
10027
for (j = 0 ; j < n_res ; j ++ ) {
10026
10028
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10027
10029
res [k ++ ] = mapped [j ];
@@ -10038,15 +10040,16 @@ do_swapcase(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4
10038
10040
Py_UCS4 c = PyUnicode_READ (kind , data , i ), mapped [3 ];
10039
10041
int n_res , j ;
10040
10042
if (Py_UNICODE_ISUPPER (c )) {
10041
- n_res = lower_ucs4 (kind , data , length , i , c , mapped , 3 );
10043
+ n_res = lower_ucs4 (kind , data , length , i , c , mapped , Py_ARRAY_LENGTH ( mapped ) );
10042
10044
}
10043
10045
else if (Py_UNICODE_ISLOWER (c )) {
10044
- n_res = PyUnicode_ToUpper (c , mapped , 3 );
10046
+ n_res = PyUnicode_ToUpper (c , mapped , Py_ARRAY_LENGTH ( mapped ) );
10045
10047
}
10046
10048
else {
10047
10049
n_res = 1 ;
10048
10050
mapped [0 ] = c ;
10049
10051
}
10052
+ assert (n_res >= 1 );
10050
10053
for (j = 0 ; j < n_res ; j ++ ) {
10051
10054
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10052
10055
res [k ++ ] = mapped [j ];
@@ -10065,9 +10068,10 @@ do_upper_or_lower(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res,
10065
10068
Py_UCS4 c = PyUnicode_READ (kind , data , i ), mapped [3 ];
10066
10069
int n_res , j ;
10067
10070
if (lower )
10068
- n_res = lower_ucs4 (kind , data , length , i , c , mapped , 3 );
10071
+ n_res = lower_ucs4 (kind , data , length , i , c , mapped , Py_ARRAY_LENGTH ( mapped ) );
10069
10072
else
10070
- n_res = PyUnicode_ToUpper (c , mapped , 3 );
10073
+ n_res = PyUnicode_ToUpper (c , mapped , Py_ARRAY_LENGTH (mapped ));
10074
+ assert (n_res >= 1 );
10071
10075
for (j = 0 ; j < n_res ; j ++ ) {
10072
10076
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10073
10077
res [k ++ ] = mapped [j ];
@@ -10096,7 +10100,8 @@ do_casefold(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4
10096
10100
for (i = 0 ; i < length ; i ++ ) {
10097
10101
Py_UCS4 c = PyUnicode_READ (kind , data , i );
10098
10102
Py_UCS4 mapped [3 ];
10099
- int j , n_res = PyUnicode_ToFolded (c , mapped , 3 );
10103
+ int j , n_res = PyUnicode_ToFolded (c , mapped , Py_ARRAY_LENGTH (mapped ));
10104
+ assert (n_res >= 1 );
10100
10105
for (j = 0 ; j < n_res ; j ++ ) {
10101
10106
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10102
10107
res [k ++ ] = mapped [j ];
@@ -10118,10 +10123,10 @@ do_title(int kind, const void *data, Py_ssize_t length, Py_UCS4 *res, Py_UCS4 *m
10118
10123
int n_res , j ;
10119
10124
10120
10125
if (previous_is_cased )
10121
- n_res = lower_ucs4 (kind , data , length , i , c , mapped , 3 );
10126
+ n_res = lower_ucs4 (kind , data , length , i , c , mapped , Py_ARRAY_LENGTH ( mapped ) );
10122
10127
else
10123
- n_res = PyUnicode_ToTitle (c , mapped , 3 );
10124
-
10128
+ n_res = PyUnicode_ToTitle (c , mapped , Py_ARRAY_LENGTH ( mapped ) );
10129
+ assert ( n_res >= 1 );
10125
10130
for (j = 0 ; j < n_res ; j ++ ) {
10126
10131
* maxchar = Py_MAX (* maxchar , mapped [j ]);
10127
10132
res [k ++ ] = mapped [j ];
0 commit comments