@@ -560,7 +560,10 @@ new_identifier(const char *n, struct compiling *c)
560560 id = id2 ;
561561 }
562562 PyUnicode_InternInPlace (& id );
563- PyArena_AddPyObject (c -> c_arena , id );
563+ if (PyArena_AddPyObject (c -> c_arena , id ) < 0 ) {
564+ Py_DECREF (id );
565+ return NULL ;
566+ }
564567 return id ;
565568}
566569
@@ -1847,7 +1850,10 @@ ast_for_atom(struct compiling *c, const node *n)
18471850 }
18481851 return NULL ;
18491852 }
1850- PyArena_AddPyObject (c -> c_arena , str );
1853+ if (PyArena_AddPyObject (c -> c_arena , str ) < 0 ) {
1854+ Py_DECREF (str );
1855+ return NULL ;
1856+ }
18511857 if (bytesmode )
18521858 return Bytes (str , LINENO (n ), n -> n_col_offset , c -> c_arena );
18531859 else
@@ -1858,7 +1864,10 @@ ast_for_atom(struct compiling *c, const node *n)
18581864 if (!pynum )
18591865 return NULL ;
18601866
1861- PyArena_AddPyObject (c -> c_arena , pynum );
1867+ if (PyArena_AddPyObject (c -> c_arena , pynum ) < 0 ) {
1868+ Py_DECREF (pynum );
1869+ return NULL ;
1870+ }
18621871 return Num (pynum , LINENO (n ), n -> n_col_offset , c -> c_arena );
18631872 }
18641873 case ELLIPSIS : /* Ellipsis */
@@ -2845,13 +2854,19 @@ alias_for_import_name(struct compiling *c, const node *n, int store)
28452854 return NULL ;
28462855 str = uni ;
28472856 PyUnicode_InternInPlace (& str );
2848- PyArena_AddPyObject (c -> c_arena , str );
2857+ if (PyArena_AddPyObject (c -> c_arena , str ) < 0 ) {
2858+ Py_DECREF (str );
2859+ return NULL ;
2860+ }
28492861 return alias (str , NULL , c -> c_arena );
28502862 }
28512863 break ;
28522864 case STAR :
28532865 str = PyUnicode_InternFromString ("*" );
2854- PyArena_AddPyObject (c -> c_arena , str );
2866+ if (PyArena_AddPyObject (c -> c_arena , str ) < 0 ) {
2867+ Py_DECREF (str );
2868+ return NULL ;
2869+ }
28552870 return alias (str , NULL , c -> c_arena );
28562871 default :
28572872 PyErr_Format (PyExc_SystemError ,
0 commit comments