From patchwork Mon Oct 26 10:11:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 23228 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 272EA44A374 for ; Mon, 26 Oct 2020 12:12:33 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1552D68AD4C; Mon, 26 Oct 2020 12:12:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3C39268ACE4 for ; Mon, 26 Oct 2020 12:12:25 +0200 (EET) Received: by mail-wr1-f66.google.com with SMTP id i1so11726442wro.1 for ; Mon, 26 Oct 2020 03:12:25 -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:reply-to :mime-version:content-transfer-encoding; bh=q5vw+kbHceI/NKueYa3AFcRiIw8ZMiBSkGSezMDCPpo=; b=RYFSPsCgLXZxjhkYTRB3H5FayQDPLa9jU568Rry6sbmOz4eNh7sBIGAci2i+sZ/5nI UFbKWYNig2UoM7kDSt5pIwGRnQhyn/2hG19Q3efMEoTVVOtK0p21iOjvNBDldBYiE4rT ITB4NXW5MjsGuTe14oQKpDevOAM13IdRCNsZ4Fkq3PABOkItOcDDiaUSAoZ7e2tkMT/V ZH+q3SC2Ky9cgD+TrMTm3bt/T9B2bD6u64T0DAIXRAnp/GkeGh4xHp39FoB//RGkzJoC +/Fp7QVncfmINnYYOQI4sthW++v5dA8BJzdRnKCOONMcphkBvEn9R89fuaZOWZhOfcy8 Fjig== 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=q5vw+kbHceI/NKueYa3AFcRiIw8ZMiBSkGSezMDCPpo=; b=oZnCBPk7kTrIce3E4JRRkJcCkyLLGBwbEfMh4bUGKxGo42emOcrf7k8gmrQ8bmQAN8 ozRNEDS4bMqe5nVg7+AciLCNk1FNyrwfkn4I6lguBjigkRo/96Q6o0NDA1FhU3/dZV4J ij5CuUuov0/JXj6t5WIF15tWHeChiIsJFODg9kPBLDXNf7ueIkplwz216gCmKCHyBf4y iX+gpj5jbwTEuj4notcjvOb5Y1Bj99dpaKpq3gHu4FDu6LJSCUmyJFtxktKjZy8zC6H/ DEH/IXT/vqdG/IvO9CaxZ/l1P8vi+jOYOa1yivmGE8cr5jswYEIE9f7o5/6OerS76jnG DELA== X-Gm-Message-State: AOAM532+z60TL+L7NjwCOeqPegp3g0hbjCEnafrJfxzCYfgxssx2xahj KTn6Icfdp6eUvuwPSzj1gMBAK7fQ9j8= X-Google-Smtp-Source: ABdhPJwPetI+s/72m/dLwth9Rwe97/jwQTaM+Hlh1NPm+IYHgl7xzmRpx6I23cReD+A/g1ygUE664A== X-Received: by 2002:adf:e8d0:: with SMTP id k16mr16613928wrn.362.1603707144438; Mon, 26 Oct 2020 03:12:24 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id n83sm21186337wma.39.2020.10.26.03.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 03:12:23 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Oct 2020 11:11:50 +0100 Message-Id: <20201026101150.425151-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026101150.425151-1-andreas.rheinhardt@gmail.com> References: <20201026101150.425151-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/bitstream: Consistently treat symbol as VLC_TYPE 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" If a static VLC table gets initialized a second time (or concurrently by two threads) and if said VLC table uses symbols that have the sign bit of VLC_TYPE (a typedef for int16_t) set, initializing the VLC fails. The reason is that the type of the symbol in the temporary array is an uint16_t and so comparing it to the symbol read from the VLC table will fail, because only the lower 16bits coincide. Said failure triggers an assert. Signed-off-by: Andreas Rheinhardt --- Found when playing around a bit with making the ClearVideo VLCs static. libavcodec/bitstream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 39749c6092..a908c10980 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -129,7 +129,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) typedef struct VLCcode { uint8_t bits; - uint16_t symbol; + VLC_TYPE symbol; /** codeword, with the first bit-to-be-read in the msb * (even if intended for a little-endian bitstream reader) */ uint32_t code;