File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,8 @@ Core and Builtins
24
24
Library
25
25
-------
26
26
27
+ - Issue #24522: Fix possible integer overflow in json accelerator module.
28
+
27
29
- Issue #24489: ensure a previously set C errno doesn't disturb cmath.polar().
28
30
29
31
- Issue #24408: Fixed AttributeError in measure() and metrics() methods of
Original file line number Diff line number Diff line change @@ -249,17 +249,23 @@ escape_unicode(PyObject *pystr)
249
249
/* Compute the output size */
250
250
for (i = 0 , output_size = 2 ; i < input_chars ; i ++ ) {
251
251
Py_UCS4 c = PyUnicode_READ (kind , input , i );
252
+ Py_ssize_t d ;
252
253
switch (c ) {
253
254
case '\\' : case '"' : case '\b' : case '\f' :
254
255
case '\n' : case '\r' : case '\t' :
255
- output_size + = 2 ;
256
+ d = 2 ;
256
257
break ;
257
258
default :
258
259
if (c <= 0x1f )
259
- output_size + = 6 ;
260
+ d = 6 ;
260
261
else
261
- output_size ++ ;
262
+ d = 1 ;
263
+ }
264
+ if (output_size > PY_SSIZE_T_MAX - d ) {
265
+ PyErr_SetString (PyExc_OverflowError , "string is too long to escape" );
266
+ return NULL ;
262
267
}
268
+ output_size += d ;
263
269
}
264
270
265
271
rval = PyUnicode_New (output_size , maxchar );
You can’t perform that action at this time.
0 commit comments