@@ -963,7 +963,6 @@ static int upipe_avfilt_avframe_from_uref_pic(struct upipe *upipe,
963963
964964 int err = upipe_av_set_frame_properties (upipe , frame , flow_def , uref );
965965 if (!ubase_check (err )) {
966- uref_free (uref );
967966 return err ;
968967 }
969968
@@ -984,7 +983,6 @@ static int upipe_avfilt_avframe_from_uref_pic(struct upipe *upipe,
984983
985984inval :
986985 upipe_warn (upipe , "invalid buffer received" );
987- uref_free (uref );
988986 return UBASE_ERR_INVALID ;
989987}
990988
@@ -1055,7 +1053,6 @@ static int upipe_avfilt_avframe_from_uref_sound(struct upipe *upipe,
10551053
10561054inval :
10571055 upipe_warn (upipe , "invalid buffer received" );
1058- uref_free (uref );
10591056 return UBASE_ERR_INVALID ;
10601057}
10611058
@@ -1073,7 +1070,10 @@ static int upipe_avfilt_avframe_from_uref(struct upipe *upipe,
10731070 struct uref * flow_def ,
10741071 AVFrame * frame )
10751072{
1076- if (ubase_check (uref_flow_match_def (flow_def , UREF_PIC_FLOW_DEF )))
1073+ if (unlikely (!flow_def )) {
1074+ upipe_warn (upipe , "no flow def set" );
1075+ return UBASE_ERR_INVALID ;
1076+ } else if (ubase_check (uref_flow_match_def (flow_def , UREF_PIC_FLOW_DEF )))
10771077 return upipe_avfilt_avframe_from_uref_pic (
10781078 upipe , uref , flow_def , frame );
10791079 else if (ubase_check (uref_flow_match_def (flow_def , UREF_SOUND_FLOW_DEF )))
@@ -1129,6 +1129,7 @@ static void upipe_avfilt_sub_input(struct upipe *upipe,
11291129 frame );
11301130 if (unlikely (!ubase_check (ret ))) {
11311131 upipe_throw_error (upipe , ret );
1132+ uref_free (uref );
11321133 av_frame_free (& frame );
11331134 return ;
11341135 }
@@ -1930,11 +1931,13 @@ static void upipe_avfilt_input(struct upipe *upipe,
19301931 upipe_avfilt -> uref = uref ;
19311932
19321933 if (!ubase_check (ubuf_av_get_avframe (uref -> ubuf , frame ))) {
1933- ret = upipe_avfilt_avframe_from_uref (upipe , uref_dup (uref ),
1934+ struct uref * uref_tmp = uref_dup (uref );
1935+ ret = upipe_avfilt_avframe_from_uref (upipe , uref_tmp ,
19341936 upipe_avfilt -> flow_def_input ,
19351937 frame );
19361938 if (!ubase_check (ret )) {
19371939 upipe_throw_error (upipe , ret );
1940+ uref_free (uref_tmp );
19381941 goto end ;
19391942 }
19401943 }
0 commit comments