[clang] [Clang] Prevent null pointer dereference in TransformUnaryTransformType() (PR #97912)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 6 14:04:28 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/97912
This patch adds null check after TransformType call to avoid dereferencing a null pointer when calling getType().
>From c30e531027828d7b531d3791c48779b465e69360 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Sat, 6 Jul 2024 14:02:16 -0700
Subject: [PATCH] [Clang] Prevent null pointer dereference in
TransformUnaryTransformType
This patch adds null check after TransformType call to avoid dereferencing a null pointer when calling getType().
---
clang/lib/Sema/TreeTransform.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4450ebaf615cd2..eb60528509fc53 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6734,8 +6734,12 @@ QualType TreeTransform<Derived>::TransformUnaryTransformType(
QualType Result = TL.getType();
if (Result->isDependentType()) {
const UnaryTransformType *T = TL.getTypePtr();
- QualType NewBase =
- getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
+
+ QualType NewBaseType = getDerived().TransformType(TL.getUnderlyingTInfo());
+ if (!NewBaseType)
+ return QualType();
+ QualType NewBase = NewBaseType->getType();
+
Result = getDerived().RebuildUnaryTransformType(NewBase,
T->getUTTKind(),
TL.getKWLoc());
More information about the cfe-commits
mailing list