@@ -6688,7 +6688,10 @@ insert_prefix_instructions(struct compiler_unit *u, basicblock *entryblock,
6688
6688
.i_loc = NO_LOCATION ,
6689
6689
.i_target = NULL ,
6690
6690
};
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
+ }
6692
6695
ncellsused += 1 ;
6693
6696
}
6694
6697
PyMem_RawFree (sorted );
@@ -6860,7 +6863,7 @@ optimize_and_assemble_code_unit(struct compiler_unit *u, PyObject *const_cache,
6860
6863
maxdepth , g .g_entryblock , nlocalsplus ,
6861
6864
code_flags , filename );
6862
6865
6863
- error :
6866
+ error :
6864
6867
Py_XDECREF (consts );
6865
6868
instr_sequence_fini (& optimized_instrs );
6866
6869
_PyCfgBuilder_Fini (& g );
@@ -6958,7 +6961,9 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
6958
6961
6959
6962
for (int i = 0 ; i < num_insts ; i ++ ) {
6960
6963
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
+ }
6962
6967
}
6963
6968
PyObject * item = PyList_GET_ITEM (instructions , i );
6964
6969
if (!PyTuple_Check (item ) || PyTuple_GET_SIZE (item ) != 6 ) {
@@ -6996,10 +7001,14 @@ instructions_to_instr_sequence(PyObject *instructions, instr_sequence *seq)
6996
7001
if (PyErr_Occurred ()) {
6997
7002
goto error ;
6998
7003
}
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
+ }
7000
7007
}
7001
7008
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
+ }
7003
7012
}
7004
7013
PyMem_Free (is_target );
7005
7014
return SUCCESS ;
@@ -7014,12 +7023,17 @@ instructions_to_cfg(PyObject *instructions, cfg_builder *g)
7014
7023
instr_sequence seq ;
7015
7024
memset (& seq , 0 , sizeof (instr_sequence ));
7016
7025
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
+ }
7021
7032
instr_sequence_fini (& seq );
7022
7033
return SUCCESS ;
7034
+ error :
7035
+ instr_sequence_fini (& seq );
7036
+ return ERROR ;
7023
7037
}
7024
7038
7025
7039
static PyObject *
0 commit comments