@@ -6689,7 +6689,10 @@ insert_prefix_instructions(struct compiler_unit *u, basicblock *entryblock,
6689
6689
.i_loc = NO_LOCATION ,
6690
6690
.i_target = NULL ,
6691
6691
};
6692
- RETURN_IF_ERROR (_PyBasicblock_InsertInstruction (entryblock , ncellsused , & make_cell ));
6692
+ if (_PyBasicblock_InsertInstruction (entryblock , ncellsused , & make_cell ) < 0 ) {
6693
+ PyMem_RawFree (sorted );
6694
+ return ERROR ;
6695
+ }
6693
6696
ncellsused += 1 ;
6694
6697
}
6695
6698
PyMem_RawFree (sorted );
@@ -6861,7 +6864,7 @@ optimize_and_assemble_code_unit(struct compiler_unit *u, PyObject *const_cache,
6861
6864
maxdepth , g .g_entryblock , nlocalsplus ,
6862
6865
code_flags , filename );
6863
6866
6864
- error :
6867
+ error :
6865
6868
Py_XDECREF (consts );
6866
6869
instr_sequence_fini (& optimized_instrs );
6867
6870
_PyCfgBuilder_Fini (& g );
@@ -6959,7 +6962,9 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
6959
6962
6960
6963
for (int i = 0 ; i < num_insts ; i ++ ) {
6961
6964
if (is_target [i ]) {
6962
- RETURN_IF_ERROR (instr_sequence_use_label (seq , i ));
6965
+ if (instr_sequence_use_label (seq , i ) < 0 ) {
6966
+ goto error ;
6967
+ }
6963
6968
}
6964
6969
PyObject * item = PyList_GET_ITEM (instructions , i );
6965
6970
if (!PyTuple_Check (item ) || PyTuple_GET_SIZE (item ) != 6 ) {
@@ -6997,10 +7002,14 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
6997
7002
if (PyErr_Occurred ()) {
6998
7003
goto error ;
6999
7004
}
7000
- RETURN_IF_ERROR (instr_sequence_addop (seq , opcode , oparg , loc ));
7005
+ if (instr_sequence_addop (seq , opcode , oparg , loc ) < 0 ) {
7006
+ goto error ;
7007
+ }
7001
7008
}
7002
7009
if (seq -> s_used && !IS_TERMINATOR_OPCODE (seq -> s_instrs [seq -> s_used - 1 ].i_opcode )) {
7003
- RETURN_IF_ERROR (instr_sequence_addop (seq , RETURN_VALUE , 0 , NO_LOCATION ));
7010
+ if (instr_sequence_addop (seq , RETURN_VALUE , 0 , NO_LOCATION ) < 0 ) {
7011
+ goto error ;
7012
+ }
7004
7013
}
7005
7014
PyMem_Free (is_target );
7006
7015
return SUCCESS ;
@@ -7015,12 +7024,17 @@ instructions_to_cfg(PyObject *instructions, cfg_builder *g)
7015
7024
instr_sequence seq ;
7016
7025
memset (& seq , 0 , sizeof (instr_sequence ));
7017
7026
7018
- RETURN_IF_ERROR (
7019
- instructions_to_instr_sequence (instructions , & seq ));
7020
-
7021
- RETURN_IF_ERROR (instr_sequence_to_cfg (& seq , g ));
7027
+ if (instructions_to_instr_sequence (instructions , & seq ) < 0 ) {
7028
+ goto error ;
7029
+ }
7030
+ if (instr_sequence_to_cfg (& seq , g ) < 0 ) {
7031
+ goto error ;
7032
+ }
7022
7033
instr_sequence_fini (& seq );
7023
7034
return SUCCESS ;
7035
+ error :
7036
+ instr_sequence_fini (& seq );
7037
+ return ERROR ;
7024
7038
}
7025
7039
7026
7040
static PyObject *
0 commit comments