This fixes two problems:
- the invalid pad.name stack pointer after init() ends
- the duplicated name for all inputs
... | ... |
@@ -24,6 +24,7 @@ |
24 | 24 |
*/ |
25 | 25 |
|
26 | 26 |
#include "libavutil/audioconvert.h" |
27 |
+#include "libavutil/avstring.h" |
|
27 | 28 |
#include "libavutil/bprint.h" |
28 | 29 |
#include "libavutil/opt.h" |
29 | 30 |
#include "libswresample/swresample.h" // only for SWR_CH_MAX |
... | ... |
@@ -61,8 +62,10 @@ static av_cold void uninit(AVFilterContext *ctx) |
61 | 61 |
AMergeContext *am = ctx->priv; |
62 | 62 |
int i; |
63 | 63 |
|
64 |
- for (i = 0; i < am->nb_inputs; i++) |
|
64 |
+ for (i = 0; i < am->nb_inputs; i++) { |
|
65 | 65 |
ff_bufqueue_discard_all(&am->in[i].queue); |
66 |
+ av_freep(&ctx->input_pads[i].name); |
|
67 |
+ } |
|
66 | 68 |
av_freep(&am->in); |
67 | 69 |
} |
68 | 70 |
|
... | ... |
@@ -293,7 +296,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args) |
293 | 293 |
{ |
294 | 294 |
AMergeContext *am = ctx->priv; |
295 | 295 |
int ret, i; |
296 |
- char name[16]; |
|
297 | 296 |
|
298 | 297 |
am->class = &amerge_class; |
299 | 298 |
av_opt_set_defaults(am); |
... | ... |
@@ -306,13 +308,15 @@ static av_cold int init(AVFilterContext *ctx, const char *args) |
306 | 306 |
if (!am->in) |
307 | 307 |
return AVERROR(ENOMEM); |
308 | 308 |
for (i = 0; i < am->nb_inputs; i++) { |
309 |
+ char *name = av_asprintf("in%d", i); |
|
310 |
+ if (!name) |
|
311 |
+ return AVERROR(ENOMEM); |
|
309 | 312 |
AVFilterPad pad = { |
310 | 313 |
.name = name, |
311 | 314 |
.type = AVMEDIA_TYPE_AUDIO, |
312 | 315 |
.filter_samples = filter_samples, |
313 | 316 |
.min_perms = AV_PERM_READ | AV_PERM_PRESERVE, |
314 | 317 |
}; |
315 |
- snprintf(name, sizeof(name), "in%d", i); |
|
316 | 318 |
ff_insert_inpad(ctx, i, &pad); |
317 | 319 |
} |
318 | 320 |
return 0; |