[clang] Avoid printing overly large integer. (PR #75902)
Nhat Nguyen via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 19 00:04:30 PST 2023
https://github.com/changkhothuychung created https://github.com/llvm/llvm-project/pull/75902
Created a PR to fix issue #71675
>From 0eb58740f33f2eef29c28e43e78118f9f0eea4b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= <“nhat7203 at gmail.com”>
Date: Tue, 19 Dec 2023 00:03:28 -0800
Subject: [PATCH] return false if the value is too large
---
clang/lib/Sema/SemaDeclCXX.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a3f68d4ffc0f6e..18631ec7dac152 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,6 +17132,9 @@ static bool ConvertAPValueToString(const APValue &V, QualType T,
case BuiltinType::WChar_U: {
unsigned TyWidth = Context.getIntWidth(T);
assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
+ if (V.getInt() >= (1 << 64)) {
+ return false;
+ }
uint32_t CodeUnit = static_cast<uint32_t>(V.getInt().getZExtValue());
WriteCharTypePrefix(BTy->getKind(), OS);
OS << '\'';
More information about the cfe-commits
mailing list