From patchwork Tue Sep 15 07:39:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22387 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 21AF444B636 for ; Tue, 15 Sep 2020 10:40:39 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0AD0468B9B9; Tue, 15 Sep 2020 10:40:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 383CA68B77C for ; Tue, 15 Sep 2020 10:40:37 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id o5so2102147wrn.13 for ; Tue, 15 Sep 2020 00:40:37 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=LYLE+Ag0sfYxIYfFwS6UL47uAHcPO31karHGGjoju8I=; b=YkIvWUYG5ltGqhSWivJHFXh26tBVf9ZMXafgzgy6ldhx6EdsKsG7j2T+l6MW+2s4jB hGZCH81/CfHvyqXMC/FFZpRPBYMLpQClH2spHL4zIZjW5u258P3XnRX9piTOgn2/H7se /uYBvGcFTgRz/YS99IynCa0iUNcXMjNmqbaZ6qzCGu6MdvWN+p/bXM9z90DTJPBxvZdF //7JJ/wmWoqgQ5rMO3d0QZpXoK969FjBXBtQpjHuDE5Gq1b7JksOju40CM/+zo+W0Dxp S5BQCJwt5j+/AM6wAwb6AU2M5NgFGjyGmebwXobNhe6UHP1ZVCTHV24E+ctlo43KzBHi pPGw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=LYLE+Ag0sfYxIYfFwS6UL47uAHcPO31karHGGjoju8I=; b=T8p0GjH9Fe2p4HGsP+Js31K1pAVEhtNwOr5JlFTiSdfH3OfeiPeTSjG3IhOms2hgms yzyZ5ebvgyZR4piRYrG44VbplFr1xpyP7IaLVnrRaPfGTvSRs+Z9JoiXNzDYDWFU20hO 7+BIFEzm8A/l2P6/B9ayfzeJ2o0eTEp1RWChQLlWC9DlgR00VQ9mFrmR8bS4MotiTheW x7NmSE8AmHhjBY4LdZ72O2idsTZF6T/n19iubDMZ2H+son7EvD35GTwjzAU7qwuX0uhC Wy3vwZiPbV28ryCaGmKrRobA2/zdiy3Xb1eJ9AK1ZQsFATUNnSDvfIKS8OwtZ9ETqeR4 zrGQ== X-Gm-Message-State: AOAM532fK86gjbG2ymgM8W2yMAoq3bV2ZaSTkt1/fQGnsxkw51ygWRla pnFqeB1B4/oxKdp3n2ZF5ZVYLHt+YS4= X-Google-Smtp-Source: ABdhPJyASmdSE0/USxz/yiNou9vVf5hXbSlIebDtVfq1apC0f4u6DIDnExtEIxsVp+onsLhgf8PPHw== X-Received: by 2002:a5d:4cc1:: with SMTP id c1mr19840475wrt.122.1600155636304; Tue, 15 Sep 2020 00:40:36 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id d23sm6112125wmb.6.2020.09.15.00.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 00:40:35 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Sep 2020 09:39:40 +0200 Message-Id: <20200915074000.102622-10-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200915074000.102622-1-andreas.rheinhardt@gmail.com> References: <20200915074000.102622-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/30] avcodec/hnm4video: Don't return nonsense error messages 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The HNM 4 video decoder's init function claimed that an allocation failed if the image dimensions are wrong. This is fixed in this commit: The dimensions are checked before the allocations are attempted. The check whether width * height is zero is redundant as av_image_check_size() already checks for this; it has been removed. Signed-off-by: Andreas Rheinhardt --- libavcodec/hnm4video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c index ac080e398b..173691a1eb 100644 --- a/libavcodec/hnm4video.c +++ b/libavcodec/hnm4video.c @@ -473,6 +473,8 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) return ret; + if (avctx->height & 1) + return AVERROR(EINVAL); hnm->version = avctx->extradata[0]; avctx->pix_fmt = AV_PIX_FMT_PAL8; @@ -482,9 +484,7 @@ static av_cold int hnm_decode_init(AVCodecContext *avctx) hnm->buffer2 = av_mallocz(avctx->width * avctx->height); hnm->processed = av_mallocz(avctx->width * avctx->height); - if ( !hnm->buffer1 || !hnm->buffer2 || !hnm->processed - || avctx->width * avctx->height == 0 - || avctx->height % 2) { + if (!hnm->buffer1 || !hnm->buffer2 || !hnm->processed) { av_log(avctx, AV_LOG_ERROR, "av_mallocz() failed\n"); return AVERROR(ENOMEM); }