@@ -6688,7 +6688,10 @@ insert_prefix_instructions(struct compiler_unit *u, basicblock *entryblock,
66886688 .i_loc = NO_LOCATION ,
66896689 .i_target = NULL ,
66906690 };
6691- RETURN_IF_ERROR (_PyBasicblock_InsertInstruction (entryblock , ncellsused , & make_cell ));
6691+ if (_PyBasicblock_InsertInstruction (entryblock , ncellsused , & make_cell ) < 0 ) {
6692+ PyMem_RawFree (sorted );
6693+ return ERROR ;
6694+ }
66926695 ncellsused += 1 ;
66936696 }
66946697 PyMem_RawFree (sorted );
@@ -6860,7 +6863,7 @@ optimize_and_assemble_code_unit(struct compiler_unit *u, PyObject *const_cache,
68606863 maxdepth , g .g_entryblock , nlocalsplus ,
68616864 code_flags , filename );
68626865
6863- error :
6866+ error :
68646867 Py_XDECREF (consts );
68656868 instr_sequence_fini (& optimized_instrs );
68666869 _PyCfgBuilder_Fini (& g );
@@ -6958,7 +6961,9 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
69586961
69596962 for (int i = 0 ; i < num_insts ; i ++ ) {
69606963 if (is_target [i ]) {
6961- RETURN_IF_ERROR (instr_sequence_use_label (seq , i ));
6964+ if (instr_sequence_use_label (seq , i ) < 0 ) {
6965+ goto error ;
6966+ }
69626967 }
69636968 PyObject * item = PyList_GET_ITEM (instructions , i );
69646969 if (!PyTuple_Check (item ) || PyTuple_GET_SIZE (item ) != 6 ) {
@@ -6996,10 +7001,14 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
69967001 if (PyErr_Occurred ()) {
69977002 goto error ;
69987003 }
6999- RETURN_IF_ERROR (instr_sequence_addop (seq , opcode , oparg , loc ));
7004+ if (instr_sequence_addop (seq , opcode , oparg , loc ) < 0 ) {
7005+ goto error ;
7006+ }
70007007 }
70017008 if (seq -> s_used && !IS_TERMINATOR_OPCODE (seq -> s_instrs [seq -> s_used - 1 ].i_opcode )) {
7002- RETURN_IF_ERROR (instr_sequence_addop (seq , RETURN_VALUE , 0 , NO_LOCATION ));
7009+ if (instr_sequence_addop (seq , RETURN_VALUE , 0 , NO_LOCATION ) < 0 ) {
7010+ goto error ;
7011+ }
70037012 }
70047013 PyMem_Free (is_target );
70057014 return SUCCESS ;
@@ -7014,12 +7023,17 @@ instructions_to_cfg(PyObject *instructions, cfg_builder *g)
70147023 instr_sequence seq ;
70157024 memset (& seq , 0 , sizeof (instr_sequence ));
70167025
7017- RETURN_IF_ERROR (
7018- instructions_to_instr_sequence (instructions , & seq ));
7019-
7020- RETURN_IF_ERROR (instr_sequence_to_cfg (& seq , g ));
7026+ if (instructions_to_instr_sequence (instructions , & seq ) < 0 ) {
7027+ goto error ;
7028+ }
7029+ if (instr_sequence_to_cfg (& seq , g ) < 0 ) {
7030+ goto error ;
7031+ }
70217032 instr_sequence_fini (& seq );
70227033 return SUCCESS ;
7034+ error :
7035+ instr_sequence_fini (& seq );
7036+ return ERROR ;
70237037}
70247038
70257039static PyObject *
0 commit comments