@@ -667,8 +667,8 @@ codegen_unwind_fblock_stack(compiler *c, location *ploc,
667667 _PyCompile_PopFBlock (c , top -> fb_type , top -> fb_block );
668668 RETURN_IF_ERROR (codegen_unwind_fblock (c , ploc , & copy , preserve_tos ));
669669 RETURN_IF_ERROR (codegen_unwind_fblock_stack (c , ploc , preserve_tos , loop ));
670- _PyCompile_PushFBlock (c , copy .fb_loc , copy .fb_type , copy .fb_block ,
671- copy .fb_exit , copy .fb_datum );
670+ RETURN_IF_ERROR ( _PyCompile_PushFBlock (c , copy .fb_loc , copy .fb_type , copy .fb_block ,
671+ copy .fb_exit , copy .fb_datum )) ;
672672 return SUCCESS ;
673673}
674674
@@ -715,10 +715,14 @@ codegen_setup_annotations_scope(compiler *c, location loc,
715715
716716 // if .format > VALUE_WITH_FAKE_GLOBALS: raise NotImplementedError
717717 PyObject * value_with_fake_globals = PyLong_FromLong (_Py_ANNOTATE_FORMAT_VALUE_WITH_FAKE_GLOBALS );
718+ if (value_with_fake_globals == NULL ) {
719+ return ERROR ;
720+ }
721+
718722 assert (!SYMTABLE_ENTRY (c )-> ste_has_docstring );
719723 _Py_DECLARE_STR (format , ".format" );
720724 ADDOP_I (c , loc , LOAD_FAST , 0 );
721- ADDOP_LOAD_CONST (c , loc , value_with_fake_globals );
725+ ADDOP_LOAD_CONST_NEW (c , loc , value_with_fake_globals );
722726 ADDOP_I (c , loc , COMPARE_OP , (Py_GT << 5 ) | compare_masks [Py_GT ]);
723727 NEW_JUMP_TARGET_LABEL (c , body );
724728 ADDOP_JUMP (c , loc , POP_JUMP_IF_FALSE , body );
@@ -794,6 +798,9 @@ codegen_deferred_annotations_body(compiler *c, location loc,
794798 if (!mangled ) {
795799 return ERROR ;
796800 }
801+ // NOTE: ref of mangled can be leaked on ADDOP* and VISIT macros due to early returns
802+ // fixing would require an overhaul of these macros
803+
797804 PyObject * cond_index = PyList_GET_ITEM (conditional_annotation_indices , i );
798805 assert (PyLong_CheckExact (cond_index ));
799806 long idx = PyLong_AS_LONG (cond_index );
@@ -3279,7 +3286,10 @@ codegen_nameop(compiler *c, location loc,
32793286 }
32803287
32813288 int scope = _PyST_GetScope (SYMTABLE_ENTRY (c ), mangled );
3282- RETURN_IF_ERROR (scope );
3289+ if (scope == -1 ) {
3290+ goto error ;
3291+ }
3292+
32833293 _PyCompile_optype optype ;
32843294 Py_ssize_t arg = 0 ;
32853295 if (_PyCompile_ResolveNameop (c , mangled , scope , & optype , & arg ) < 0 ) {
0 commit comments