From patchwork Sat Oct 12 01:14:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 15706 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2B72F44A97C for ; Sat, 12 Oct 2019 04:22:27 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0460E689AC3; Sat, 12 Oct 2019 04:22:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CF06688157 for ; Sat, 12 Oct 2019 04:22:20 +0300 (EEST) Received: by mail-pg1-f176.google.com with SMTP id t3so6734743pga.8 for ; Fri, 11 Oct 2019 18:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+/harnOUYbIS8Y+ZBlfTU/XY0s2+XDIUcJU16ASKpsg=; b=CCyTkhBZDLwVUtn8w7VcmDxiLDNrsndWzhGNg5fhZKzmPyVj/4rK6eZrsRqyytvBp3 KggJrp6BceE5rS1vqTQNHg9hM8Dy2OAj1VL6B/vsCeD2emuz3vd9HAFht5iSlqfEhKxp z3+ltdrs5j4FZeDwoAQYRHKcCDR2duvD+yYr1nebUaxc3Z5/KDlfKBD5B5+c0DxDrhyU ei2sWWjpZMnsRXto8E5dn2CN17vcypZGOMY9pFEh6GlXFhhEevUBgZ/JOYPYmqe6RVsq HF4JcQZcguqfXXI8SKfCeOCDFdNhLtuir8AlbKlJYcyL+s9jSoX382hgw2e9rfbudK2H P+Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+/harnOUYbIS8Y+ZBlfTU/XY0s2+XDIUcJU16ASKpsg=; b=CwqXaJExo8JzTHfka3Or8lJB4+Pf906KSzE/g1BRJGT6/cu+3bHcK39DSSyRdmagK0 Wu71w3oJiL/Yr57hDbF2DD6eCqTaXSljEciJ3dQiKFewWC1zqSA3RtR1w5ZzTQcRQXcP UePsg0AM4WZzDhh28gILO9gedtMdkCUPu20nGb7lVjtuvBNZR4nzjrgezqBfTpCClFu7 61rnAF33sdvEfr9m9EUgomLECdxSwZ5ESQnceztehh3TfNNlnbd0WB1Pj/ymxEPidOqm lwkZuwv+jhoIK5aBxeLd2/LEP5fSVV0erOGn7EJMbSWUttozKvd9kBfMCXPBzRB9Nnpm BRAg== X-Gm-Message-State: APjAAAWP6tlIECzrpGPDpseZPTmCw3mZxe1cFwMOBiVDU2WkaOzN3KTD qCy4TU5qOBe78EixE81O/laLgXt0 X-Google-Smtp-Source: APXvYqxY4U9o6/tKI8IkA3y/lUt1lkvuiJw5/xpt6Aok+orWMvQzhxpjvr9gnbTq6ZaJs3OrYJOdRg== X-Received: by 2002:a65:408a:: with SMTP id t10mr20237611pgp.385.1570842886160; Fri, 11 Oct 2019 18:14:46 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id s1sm7706570pgi.52.2019.10.11.18.14.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 18:14:44 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Sat, 12 Oct 2019 09:14:38 +0800 Message-Id: <1570842880-22864-1-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 Subject: [FFmpeg-devel] [PATCH V1 1/3] lavfi/avf_showspectrum: add error handle if av_asprintf return null X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Jun Zhao MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Jun Zhao add error handle if av_asprintf return null. Signed-off-by: Jun Zhao --- 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 f175bf1..d5785af 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++) {