From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 78E1D4AAC6 for ; Tue, 11 Jun 2024 18:52:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5358668D8B4; Tue, 11 Jun 2024 21:52:32 +0300 (EEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 892DD68D89E for ; Tue, 11 Jun 2024 21:52:26 +0300 (EEST) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1f4a5344ec7so1336035ad.1 for ; Tue, 11 Jun 2024 11:52:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718131944; x=1718736744; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZM87yV5PjWII8SLQ4tOdxx0k3FOT6Dm9j94Xodapsos=; b=VEfW+s/5cHeqWKNzFaTFUMyT6r0Gb3IR2d8E1EYVc+oivMMr5Rhkwx5O1Pa843NGPk wW4hJhJWr64tiwcsc5EXBSsQIjufA3H3PbcXmNjMlJjAZ4FQL6DsiLZw2FhtL7bD8Pwc T8+jPyuFVPMYUkUeTFrn4A6VJARLUOyqqVuut84Do+e4y2CJj8V6eOSveis3ZK28Bcb3 lZBjl0q66MfGf34UIEq4F88lS7h6ni/wPbMdQXxgHkFu26UGq03I9Oa2yTI5A8GVbokw PiNvLZtp/Yw0EwY9gLT1+7wImgGeczkDKRpqsg27LKqO2YX8GgK2TLGj9npwFSfrrad5 DVig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718131944; x=1718736744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZM87yV5PjWII8SLQ4tOdxx0k3FOT6Dm9j94Xodapsos=; b=W25cisBQ+T8xv+W875HMd+cGNsS5fTcBNVmSs0q5QY2/Vn7b9Jxg/YMTqOuFh6ccM8 ssE1XYJn9+t7ciqb2VY4S4qHOiHyGQlgkqK4BQkzW5a52+35SUIJfaIcNnAZ983+xaPV YM1F0cPqB6H5KpbYyooSIY6PgAEFPYtL5+aePF9O8khWJODmOo6lhwGaiBiBr+iMAgam GdX+vaHFW/ef6hEsYA1FQ+DIGWyA2u79vUrdcW1bqxit9IvdPUWXo1cJV3JlMcqt6TWL SuMI+CChPkdlkogfaRUMf/Nu6xHXnQw9+mDEYeQlDe1+9m8eVkDWaT1wmv4PPFvRikmx 1oTg== X-Gm-Message-State: AOJu0Yyn9iRotrubJznxRCa1wP5NQMy8PgCc6QNoa+YzzYZFBAbJplLp JbjvANMIjjSbjoAx5td0QNeb28c4EUh0Ax/HViX1WUwvNCanXbXiZxYrAQ== X-Google-Smtp-Source: AGHT+IEpyowDljiTe+LGkgEsBVTTE+d5i6EuuJiT+e/ZJFWUf8lp8PaapVsZD23NY/ADQCbq2AEa5g== X-Received: by 2002:a17:902:dac9:b0:1f6:fac5:d5f1 with SMTP id d9443c01a7336-1f728930b6bmr50530785ad.27.1718131943757; Tue, 11 Jun 2024 11:52:23 -0700 (PDT) Received: from localhost.localdomain ([190.194.167.233]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f6bd7f309csm104586015ad.263.2024.06.11.11.52.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 11:52:23 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Tue, 11 Jun 2024 15:52:31 -0300 Message-ID: <20240611185232.5384-2-jamrial@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240611185232.5384-1-jamrial@gmail.com> References: <20240611185232.5384-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avutil/common: assert that bit position in av_zero_extend is valid X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: James Almer --- libavutil/common.h | 3 +++ libavutil/x86/intmath.h | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavutil/common.h b/libavutil/common.h index acd041fb67..65448d47d3 100644 --- a/libavutil/common.h +++ b/libavutil/common.h @@ -296,6 +296,9 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) */ static av_always_inline av_const unsigned av_zero_extend_c(unsigned a, unsigned p) { +#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 + if (p > 31) abort(); +#endif return a & ((1U << p) - 1); } diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h index 821a06ab66..de6da72129 100644 --- a/libavutil/x86/intmath.h +++ b/libavutil/x86/intmath.h @@ -90,8 +90,11 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) #define av_zero_extend av_zero_extend_bmi2 static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) { +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 + if (p > 31) abort(); +#endif if (av_builtin_constant_p(p)) - return a & ((1 << p) - 1); + return a & ((1U << p) - 1); else { unsigned x; __asm__ ("bzhi %2, %1, %0 \n\t" : "=r"(x) : "rm"(a), "r"(p)); -- 2.45.2 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".