[clang] [Clang] [NFC] Prevent null pointer dereference in Sema::InstantiateFunctionDefinition (PR #89801)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 10:41:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (smanna12)
<details>
<summary>Changes</summary>
…nctionDefinition
In the lambda function within clang::Sema::InstantiateFunctionDefinition, the return value of a function that may return null is now checked before dereferencing to avoid potential null pointer dereference issues.
---
Full diff: https://github.com/llvm/llvm-project/pull/89801.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+2)
``````````diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 787a485e0b2f8c..2490ec4ca614a8 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5183,7 +5183,9 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
Function->setTypeSourceInfo(NewSI);
ParmVarDecl *Parm = Function->getParamDecl(0);
+ assert(Parm && "First parameter not found in function declaration.");
TypeSourceInfo *NewParmSI = IR.TransformType(Parm->getTypeSourceInfo());
+ assert(NewParmSI && "Type transformation failed.");
Parm->setType(NewParmSI->getType());
Parm->setTypeSourceInfo(NewParmSI);
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/89801
More information about the cfe-commits
mailing list