@@ -1373,9 +1373,16 @@ expr_ty _PyPegen_constant_from_string(Parser* p, Token* tok) {
1373
1373
_Pypegen_raise_decode_error (p );
1374
1374
return NULL ;
1375
1375
}
1376
+ if (_PyArena_AddPyObject (p -> arena , s ) < 0 ) {
1377
+ Py_DECREF (s );
1378
+ return NULL ;
1379
+ }
1376
1380
PyObject * kind = NULL ;
1377
1381
if (the_str && the_str [0 ] == 'u' ) {
1378
1382
kind = _PyPegen_new_identifier (p , "u" );
1383
+ if (kind == NULL ) {
1384
+ return NULL ;
1385
+ }
1379
1386
}
1380
1387
return _PyAST_Constant (s , kind , tok -> lineno , tok -> col_offset , tok -> end_lineno , tok -> end_col_offset , p -> arena );
1381
1388
}
@@ -1488,7 +1495,8 @@ _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq *strings,
1488
1495
expr_ty elem = asdl_seq_GET (strings , i );
1489
1496
PyBytes_Concat (& res , elem -> v .Constant .value );
1490
1497
}
1491
- if (_PyArena_AddPyObject (arena , res ) < 0 ) {
1498
+ if (!res || _PyArena_AddPyObject (arena , res ) < 0 ) {
1499
+ Py_XDECREF (res );
1492
1500
return NULL ;
1493
1501
}
1494
1502
return _PyAST_Constant (res , kind , lineno , col_offset , end_lineno , end_col_offset , p -> arena );
@@ -1589,13 +1597,15 @@ _PyPegen_concatenate_strings(Parser *p, asdl_expr_seq *strings,
1589
1597
_PyUnicodeWriter_Dealloc (& writer );
1590
1598
return NULL ;
1591
1599
}
1592
-
1600
+ if (_PyArena_AddPyObject (p -> arena , concat_str ) < 0 ) {
1601
+ Py_DECREF (concat_str );
1602
+ return NULL ;
1603
+ }
1593
1604
elem = _PyAST_Constant (concat_str , kind , first_elem -> lineno ,
1594
1605
first_elem -> col_offset ,
1595
1606
last_elem -> end_lineno ,
1596
1607
last_elem -> end_col_offset , p -> arena );
1597
1608
if (elem == NULL ) {
1598
- Py_DECREF (concat_str );
1599
1609
return NULL ;
1600
1610
}
1601
1611
}
0 commit comments