From patchwork Fri Aug 2 20:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 14199 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 9918F4485F3 for ; Fri, 2 Aug 2019 23:38:07 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73CC168AC7E; Fri, 2 Aug 2019 23:38:07 +0300 (EEST) 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 C050068AC57 for ; Fri, 2 Aug 2019 23:38:00 +0300 (EEST) Received: by mail-wm1-f67.google.com with SMTP id x15so69139936wmj.3 for ; Fri, 02 Aug 2019 13:38:00 -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:mime-version :content-transfer-encoding; bh=fceIf3zqaqeM0WRtJ1/CFcCdFyP/M7D60evqbsCybHU=; b=Hi9eqIB1JgmK+4cAPLfDSwxVxg1Ohx3y624KpMMGsISkcvlsSgi6cxc9sLRl8cd6Zx awUQNAOeXtsOLZ5sbqhDGXZ8Kg1mSZFLh2yBoHJXe4juvgTlyc9QlOzWpypBpYgAwd3X b2ZUX0kRx1nxYzWhumAayUQq/S76vLrR9WZ1W2CCWDTUzWlVp2sJqwyjp8Whi6WiTtXy 8nskNMgWyhda9yj/olX07yoPSFvIza7+Q/gs1/tBUj1KG6ZwPhPpz/Iv5IBkY7G0NbLu e1oc2zqUCOWnS5JC1XBIFxIDTZthLHFX4YatcQkubjqXeQM/UWI6b7ynwfZGazkofZj4 ZcAA== 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:mime-version :content-transfer-encoding; bh=fceIf3zqaqeM0WRtJ1/CFcCdFyP/M7D60evqbsCybHU=; b=KCOs2TwascGF6HQLN7QPALLPsEm+hKFbRvqZ3Vl5Acs1cj2DwGABCw829v2IqAVGB4 Qrm2EduuOiCfQWEqHBLDFEYERQoy00PImKuz3c9TxjBEHSRd15VpOgAusdXH4IY8g/Ao CiQS2MspZUaqKhbBNGzGt3VBZFkC5xYaIDI26QM9TrNV0E3dMhaOxnMXdf4Ph3Q4+LMP 4LhV1eldnWqh6v3pKOkm7W8CqFhtof/7o2u12d59UVWK7MZXioXx+AAkNGMlXKuscRNm QChD+CXqqNj5+b/9BNKAiAnLymW7uWB9JLpWQpbu6RnvipYmkYkaTYRHw1BjaEaMuQ3r ztyw== X-Gm-Message-State: APjAAAWaaNAIh3dYqYrmt2ZcB0VKnTiQhOCyTL341vkRNa9xurXnPRb6 Jj17ZCtz1GjebVoOMmlBIckbnsZE X-Google-Smtp-Source: APXvYqyTTHeJEBlK4MqACK5qo7b9QLfrX85Xpx6AAShhb8nP1tC4Ggcjprn1F9gNYCNwfCb9JlhfFg== X-Received: by 2002:a1c:2e09:: with SMTP id u9mr5723639wmu.137.1564777788106; Fri, 02 Aug 2019 13:29:48 -0700 (PDT) Received: from localhost.localdomain (ipbcc08b8f.dynamic.kabel-deutschland.de. [188.192.139.143]) by smtp.gmail.com with ESMTPSA id g131sm55795740wmf.37.2019.08.02.13.29.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 13:29:47 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 2 Aug 2019 22:29:16 +0200 Message-Id: <20190802202916.11594-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavcodec/iff: Use unsigned to avoid undefined behaviour 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 initialization of the uint32_t plane32_lut matrix uses left shifts of the form 1 << plane; plane can be as big as 31 which means that this is undefined behaviour as 1 will be simply an int. So make it unsigned to avoid this. Signed-off-by: Andreas Rheinhardt --- libavcodec/iff.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 7f1c589d7c..fc7bfad731 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -111,23 +111,23 @@ static const uint64_t plane8_lut[8][256] = { LUT8(4), LUT8(5), LUT8(6), LUT8(7), }; -#define LUT32(plane) { \ - 0, 0, 0, 0, \ - 0, 0, 0, 1 << plane, \ - 0, 0, 1 << plane, 0, \ - 0, 0, 1 << plane, 1 << plane, \ - 0, 1 << plane, 0, 0, \ - 0, 1 << plane, 0, 1 << plane, \ - 0, 1 << plane, 1 << plane, 0, \ - 0, 1 << plane, 1 << plane, 1 << plane, \ - 1 << plane, 0, 0, 0, \ - 1 << plane, 0, 0, 1 << plane, \ - 1 << plane, 0, 1 << plane, 0, \ - 1 << plane, 0, 1 << plane, 1 << plane, \ - 1 << plane, 1 << plane, 0, 0, \ - 1 << plane, 1 << plane, 0, 1 << plane, \ - 1 << plane, 1 << plane, 1 << plane, 0, \ - 1 << plane, 1 << plane, 1 << plane, 1 << plane, \ +#define LUT32(plane) { \ + 0, 0, 0, 0, \ + 0, 0, 0, 1U << plane, \ + 0, 0, 1U << plane, 0, \ + 0, 0, 1U << plane, 1U << plane, \ + 0, 1U << plane, 0, 0, \ + 0, 1U << plane, 0, 1U << plane, \ + 0, 1U << plane, 1U << plane, 0, \ + 0, 1U << plane, 1U << plane, 1U << plane, \ + 1U << plane, 0, 0, 0, \ + 1U << plane, 0, 0, 1U << plane, \ + 1U << plane, 0, 1U << plane, 0, \ + 1U << plane, 0, 1U << plane, 1U << plane, \ + 1U << plane, 1U << plane, 0, 0, \ + 1U << plane, 1U << plane, 0, 1U << plane, \ + 1U << plane, 1U << plane, 1U << plane, 0, \ + 1U << plane, 1U << plane, 1U << plane, 1U << plane, \ } // 32 planes * 4-bit mask * 4 lookup tables each