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 | if (!pad.name) | 199 | if (!pad.name) |
| 200 | return AVERROR(ENOMEM); | 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 | if (s->draw_curves) { | 208 | if (s->draw_curves) { |
| 203 | vpad = (AVFilterPad){ | 209 | vpad = (AVFilterPad){ |
| 204 | .name = av_strdup("out1"), | 210 | .name = av_strdup("out1"), |
| @@ -206,18 +212,8 @@ static av_cold int init(AVFilterContext *ctx) · 1 unmodified line | |||
| 206 | .config_props = config_video, | 212 | .config_props = config_video, |
| 207 | }; | 213 | }; |
| 208 | if (!vpad.name) { | 214 | if (!vpad.name) { |
| 209 | av_freep(&pad.name); | ||
| 210 | return AVERROR(ENOMEM); | 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 | ret = ff_insert_outpad(ctx, 1, &vpad); | 217 | ret = ff_insert_outpad(ctx, 1, &vpad); |
| 222 | if (ret < 0) { | 218 | if (ret < 0) { |
| 223 | av_freep(&vpad.name); | 219 | av_freep(&vpad.name); |