diff options
author | Jun Zhao <barryjzhao@tencent.com> | 2019-10-12 00:36:19 +0800 |
---|---|---|
committer | Jun Zhao <barryjzhao@tencent.com> | 2019-10-18 09:56:27 +0800 |
commit | 85e2b222e9105d6202a2ed843350065b5b37c81d (patch) | |
tree | d98030a3db7da45d404eff9c740e86cc20fb7e70 | |
parent | 0ae6fb276bd9deba88077bd6f9cbe5d4b84e7f6f (diff) | |
download | ffmpeg-85e2b222e9105d6202a2ed843350065b5b37c81d.tar.gz |
lavfi/avf_showspectrum: add error handle if av_asprintf return null
add error handle if av_asprintf return null.
Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
-rw-r--r-- | libavfilter/avf_showspectrum.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index f175bf1cb5..d5785af252 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -695,11 +695,15 @@ static int draw_legend(AVFilterContext *ctx, int samples) inlink->channel_layout); text = av_asprintf("%d Hz | %s", inlink->sample_rate, chlayout_str); + if (!text) + return AVERROR(ENOMEM); drawtext(s->outpicref, 2, outlink->h - 10, "CREATED BY LIBAVFILTER", 0); drawtext(s->outpicref, outlink->w - 2 - strlen(text) * 10, outlink->h - 10, text, 0); if (s->stop) { char *text = av_asprintf("Zoom: %d Hz - %d Hz", s->start, s->stop); + if (!text) + return AVERROR(ENOMEM); drawtext(s->outpicref, outlink->w - 2 - strlen(text) * 10, 3, text, 0); av_freep(&text); } @@ -766,6 +770,8 @@ static int draw_legend(AVFilterContext *ctx, int samples) for (x = 0; x < s->w && s->single_pic; x+=80) { float seconds = x * spp / inlink->sample_rate; char *units = get_time(ctx, seconds, x); + if (!units) + return AVERROR(ENOMEM); drawtext(s->outpicref, s->start_x + x - 4 * strlen(units), s->h + s->start_y + 6, units, 0); drawtext(s->outpicref, s->start_x + x - 4 * strlen(units), s->start_y - 12, units, 0); @@ -822,6 +828,8 @@ static int draw_legend(AVFilterContext *ctx, int samples) for (y = 0; y < s->h && s->single_pic; y+=40) { float seconds = y * spp / inlink->sample_rate; char *units = get_time(ctx, seconds, x); + if (!units) + return AVERROR(ENOMEM); drawtext(s->outpicref, s->start_x - 8 * strlen(units) - 4, s->start_y + y - 4, units, 0); av_free(units); @@ -1360,6 +1368,8 @@ static int plot_spectrum_column(AVFilterLink *inlink, AVFrame *insamples) if (s->old_pts < outpicref->pts) { if (s->legend) { char *units = get_time(ctx, insamples->pts /(float)inlink->sample_rate, x); + if (!units) + return AVERROR(ENOMEM); if (s->orientation == VERTICAL) { for (y = 0; y < 10; y++) { |