It has been forgotten to free the name of the second outpad if attaching the first one to the AVFilterContext fails. Fixing this is easy: Only prepare the second outpad after (and if) the first outpad has been successfully attached to the AVFilterContext.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -199,6 +199,12 @@ static av_cold int init(AVFilterContext *ctx) · 198 unmodified lines | ||
| 199 | 199 | if (!pad.name) |
| 200 | 200 | return AVERROR(ENOMEM); |
| 201 | 201 | |
| 202 | + ret = ff_insert_outpad(ctx, 0, &pad); | |
| 203 | + if (ret < 0) { | |
| 204 | + av_freep(&pad.name); | |
| 205 | + return ret; | |
| 206 | + } | |
| 207 | + | |
| 202 | 208 | if (s->draw_curves) { |
| 203 | 209 | vpad = (AVFilterPad){ |
| 204 | 210 | .name = av_strdup("out1"), |
| @@ -206,18 +212,8 @@ static av_cold int init(AVFilterContext *ctx) · 1 unmodified line | ||
| 206 | 212 | .config_props = config_video, |
| 207 | 213 | }; |
| 208 | 214 | if (!vpad.name) { |
| 209 | − av_freep(&pad.name); | |
| 210 | 215 | return AVERROR(ENOMEM); |
| 211 | 216 | } |
| 212 | − } | |
| 213 | − | |
| 214 | − ret = ff_insert_outpad(ctx, 0, &pad); | |
| 215 | − if (ret < 0) { | |
| 216 | − av_freep(&pad.name); | |
| 217 | − return ret; | |
| 218 | − } | |
| 219 | − | |
| 220 | − if (s->draw_curves) { | |
| 221 | 217 | ret = ff_insert_outpad(ctx, 1, &vpad); |
| 222 | 218 | if (ret < 0) { |
| 223 | 219 | av_freep(&vpad.name); |