summaryrefslogtreecommitdiff
path: root/libavfilter/af_compand.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-26 12:49:04 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-02-26 13:00:09 +0100
commite509df4bc8eb3aebdda71b826955d581e717fb0e (patch)
tree2beb7988fb349f3cea58a73fea025a2533904b11 /libavfilter/af_compand.c
parent4b879751473227610e28005987176ae64f3cfdd6 (diff)
downloadffmpeg-e509df4bc8eb3aebdda71b826955d581e717fb0e.tar.gz
avfilter/af_compand: error checks from libavfilter/af_compand_fork.c
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/af_compand.c')
-rw-r--r--libavfilter/af_compand.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/libavfilter/af_compand.c b/libavfilter/af_compand.c
index 5ad0f49d7a..6ad4ff3973 100644
--- a/libavfilter/af_compand.c
+++ b/libavfilter/af_compand.c
@@ -183,6 +183,7 @@ static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
const int nb_samples = frame->nb_samples;
AVFrame *out_frame;
int chan, i;
+ int err;
if (av_frame_is_writable(frame)) {
out_frame = frame;
@@ -192,7 +193,12 @@ static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
av_frame_free(&frame);
return AVERROR(ENOMEM);
}
- av_frame_copy_props(out_frame, frame);
+ err = av_frame_copy_props(out_frame, frame);
+ if (err < 0) {
+ av_frame_free(&out_frame);
+ av_frame_free(&frame);
+ return err;
+ }
}
for (chan = 0; chan < channels; chan++) {
@@ -223,6 +229,7 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
const int nb_samples = frame->nb_samples;
int chan, i, av_uninit(dindex), oindex, av_uninit(count);
AVFrame *out_frame = NULL;
+ int err;
if (s->pts == AV_NOPTS_VALUE) {
s->pts = (frame->pts == AV_NOPTS_VALUE) ? 0 : frame->pts;
@@ -250,7 +257,12 @@ static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
av_frame_free(&frame);
return AVERROR(ENOMEM);
}
- av_frame_copy_props(out_frame, frame);
+ err = av_frame_copy_props(out_frame, frame);
+ if (err < 0) {
+ av_frame_free(&out_frame);
+ av_frame_free(&frame);
+ return err;
+ }
out_frame->pts = s->pts;
s->pts += av_rescale_q(nb_samples - i,
(AVRational){ 1, inlink->sample_rate },
@@ -317,6 +329,7 @@ static int config_output(AVFilterLink *outlink)
double radius = s->curve_dB * M_LN10 / 20;
int nb_attacks, nb_decays, nb_points;
char *p, *saveptr = NULL;
+ const int channels = outlink->channels;
int new_nb_items, num;
int i;
int err;
@@ -326,6 +339,11 @@ static int config_output(AVFilterLink *outlink)
count_items(s->decays, &nb_decays);
count_items(s->points, &nb_points);
+ if (channels <= 0) {
+ av_log(ctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
+ return AVERROR(EINVAL);
+ }
+
if ((nb_attacks > outlink->channels) || (nb_decays > outlink->channels)) {
av_log(ctx, AV_LOG_ERROR, "Number of attacks/decays bigger than number of channels.\n");
return AVERROR(EINVAL);