From patchwork Wed Mar 10 01:05:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26290 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 48A4B448EE5 for ; Wed, 10 Mar 2021 03:06:23 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 203B268A73D; Wed, 10 Mar 2021 03:06:23 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6BE69687F3D for ; Wed, 10 Mar 2021 03:06:16 +0200 (EET) Received: by mail-ej1-f42.google.com with SMTP id ox4so18058417ejb.11 for ; Tue, 09 Mar 2021 17:06:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; bh=Fh0QGVNgQ+KXSWZBUEwmj8CSK5xbFDaxo1OKAP4Mg6s=; b=M0/DYRGqfOhXApBO4NlaDChHtRmE02cYj2T7j4bANMi/NWP3D3g5wmJoaR0lEs7kQG WrsaOvOPug8n/cirUMvDC6Y9tIYA96VM06Rx0pX00o+rW9Kono4YJzqYeOb4z99zVQYT CA+Mvt/1QkpFL0LCNVKTFJ5UsQ9cZyHTxYAxvoouyDPPzaH10y06pJtpPHIHWd/c5Dh8 ujq/JGtxpru1oCqYIQU5wtJx1oIYixtcR+QBHI6qrZ7Gsvzz+BKA1KhdHvRGYGbDojwe XjiwVeL0E5V8MBPFk3nsexu0fBbTlL5RSzir0wnrHay5Q9QU2TY2DOM5tNcqJIrtwapb WHIA== 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:reply-to :mime-version:content-transfer-encoding; bh=Fh0QGVNgQ+KXSWZBUEwmj8CSK5xbFDaxo1OKAP4Mg6s=; b=MgSvNTzytQliqPYUVwic6gI8EzDTempXbpfo+Fcsc3FiHdmuo1uySYV/LnokSVB4qa 4pQYLyeWZ8ZbttSCK3Dnm2MUTgrk5R/JPAIZ7KJaYyonZZJrxipd3Z+aCgcvRwoOhwkp 3oY3cLOxne0z+mqPuK2OJkL5ht/jApCTFArKvpL3+WhnMmdQ3W4qXx4oF0jXLhy5x1Z2 FlvSVpjfWjwMmYeKr+picOnMQnrzrBGM7jAYQuoib3rH2YPI0YUQa3zWQbD/QavarYMM YjME6bAaXcEjYuU2MxBn3trzqurZjEHZyoF1eSpnXtopR9tzeRE/L5JdVb8VatYe8WZI lA4g== X-Gm-Message-State: AOAM532X+SfmWV78tbPREi3DDC88EOwaDLbNqh4Fnsv477Z5KK146Ncp qtzjZjMO3WGpKSzAa4MFzxFb4iG2CYY= X-Google-Smtp-Source: ABdhPJzTi6vfqv7ANjeZ50efBFNAg4S4u0xZtBzON1GHmtu7cEz+FyrnjhDb+3Z/QkU7O6BIt3iw1A== X-Received: by 2002:a17:906:9515:: with SMTP id u21mr870020ejx.86.1615338375590; Tue, 09 Mar 2021 17:06:15 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id r13sm9960737edy.3.2021.03.09.17.06.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 17:06:15 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 02:05:54 +0100 Message-Id: <20210310010601.1142819-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec 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" Setting this field happens immediately after the allocation in ff_cbs_init(), so the whole CBS code may presume that any CodedBitstreamContext has this set. Lots of code already presumed this, yet ff_cbs_close() did it inconsistently: It checked before checking whether the CodedBitstreamType has a close function; yet it simply unconditionally read ctx->codec->priv_class. Coverity complained about this in issue #1473564, which this commit fixes. Signed-off-by: Andreas Rheinhardt --- libavcodec/cbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index ecf22b3fdb..c7f69845fb 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -94,7 +94,7 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr, return AVERROR(ENOMEM); ctx->log_ctx = log_ctx; - ctx->codec = type; + ctx->codec = type; /* Must be before any error */ if (type->priv_data_size) { ctx->priv_data = av_mallocz(ctx->codec->priv_data_size); @@ -119,7 +119,7 @@ int ff_cbs_init(CodedBitstreamContext **ctx_ptr, void ff_cbs_flush(CodedBitstreamContext *ctx) { - if (ctx->codec && ctx->codec->flush) + if (ctx->codec->flush) ctx->codec->flush(ctx); } @@ -130,7 +130,7 @@ void ff_cbs_close(CodedBitstreamContext **ctx_ptr) if (!ctx) return; - if (ctx->codec && ctx->codec->close) + if (ctx->codec->close) ctx->codec->close(ctx); av_freep(&ctx->write_buffer);