From patchwork Tue Nov 10 10:47:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23505 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 AB221449A48 for ; Tue, 10 Nov 2020 12:57:16 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CA5C368BE5A; Tue, 10 Nov 2020 12:50:07 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C265968BE2A for ; Tue, 10 Nov 2020 12:49:54 +0200 (EET) Received: by mail-wm1-f67.google.com with SMTP id s13so2526506wmh.4 for ; Tue, 10 Nov 2020 02:49:54 -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:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=wPZ/njqUh7Q9dNOvCOzT6jxgW2pe0MyPMNsp7Y+aBdI=; b=gaoreHCOqRYaNUlyUsAJYXLUNgETY54AIDV7hCo6M5KoTTf5ygBPUUonlMaMZCKuDJ GEZOq8DJEiH+cLICE90cj05bQReKfa8Aq72J97eFk/WSWs01fkYTr52Mt3JVSymr1IsR rzqc/5zFh5M+eLcvsDYQWx26/NkPOYkBvPPWpOS7WMLOsHFTDcCK7Ei/IVZF1m5TWCvy rUNpiudLsNphabkD3d3xGDZQY8Egb7I2QJo/piw42TxEZxCxQPNNhoo6Bo7yK34jUQep ac88DW2qki0rW3FtfAgLhFHEV4sIsBvtNcUrX/A/ItXoVF2lRdyCdX/53BG99dReAP0Q r3tw== 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:reply-to:mime-version:content-transfer-encoding; bh=wPZ/njqUh7Q9dNOvCOzT6jxgW2pe0MyPMNsp7Y+aBdI=; b=tRKRuFB+PW/bcLM9ttQ3BwWbItDvQXD3baznIpoZsB3MF79gfm0mwb/G8IwkM5Z9e3 PDJ2DX2ABAF2Mphg3tvqYUqNFcMs0g9CyE2RSE6K78D1u3h42JlOXxGKpBm6eSF1vZ9Q cKpq79lMoaxql5C0GYklBHy/8RjoA8VWQ9weNgdWs9ptdr29JV/b43pVLujSavmq2xp5 rqQUPUaF7GSrmHc4YZu36dJ9nrCmcHbNLkmG75EPM8Fg4bONzX2WhLeagSa9JGLZRmjt Gl7XssFg3RZqxfWOFZjs6zO4R7eAYEqE8ysiVQtHd8iIb1Cuzj2ExzLhf4h15EPNo91y cxnA== X-Gm-Message-State: AOAM53251iT7A+wRDsn2PjwqWZyrVIX+6HmkNxvd94/JPTanc/jjc8GT 0X2B2PJRRTCct4mF3Jl569J/nhkZFOc= X-Google-Smtp-Source: ABdhPJxzoZgsxUeeJP3+6d5wWf9QzxPA6Fm8RsvGPXvhjhwPM9iXeBHN030d2KK15yhIEyM6aqCnEw== X-Received: by 2002:a1c:4957:: with SMTP id w84mr4060656wma.84.1605005393985; Tue, 10 Nov 2020 02:49:53 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id l24sm2572543wmi.7.2020.11.10.02.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 02:49:53 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 10 Nov 2020 11:47:31 +0100 Message-Id: <20201110104851.321029-35-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> References: <20201110104851.321029-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 034/114] avcodec/motionpixels: Be more strict when parsing Huffman trees 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" This ensures that the number of leafs in the Huffman tree equals the number it is supposed to be and therefore ensures that the VLC tree is complete, allowing us to remove checks. Signed-off-by: Andreas Rheinhardt --- Alternatively one could use mp->current_codes_count when initializing the VLC. libavcodec/motionpixels.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c index 0bf153f883..4b9830fbed 100644 --- a/libavcodec/motionpixels.c +++ b/libavcodec/motionpixels.c @@ -133,7 +133,7 @@ static int mp_get_code(MotionPixelsContext *mp, GetBitContext *gb, int size, int if (mp_get_code(mp, gb, size, code + 1) < 0) return AVERROR_INVALIDDATA; } - if (mp->current_codes_count >= MAX_HUFF_CODES) { + if (mp->current_codes_count >= mp->codes_count) { av_log(mp->avctx, AV_LOG_ERROR, "too many codes\n"); return AVERROR_INVALIDDATA; }