[clang] e58dcf1 - [Clang] [NFC] Prevent null pointer dereference in Sema::InstantiateFunctionDefinition (#89801)

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 24 06:41:55 PDT 2024


Author: smanna12
Date: 2024-04-24T08:41:51-05:00
New Revision: e58dcf135f3a6e453e7b123642675e39b8527f2d

URL: https://github.com/llvm/llvm-project/commit/e58dcf135f3a6e453e7b123642675e39b8527f2d
DIFF: https://github.com/llvm/llvm-project/commit/e58dcf135f3a6e453e7b123642675e39b8527f2d.diff

LOG: [Clang] [NFC] Prevent null pointer dereference in Sema::InstantiateFunctionDefinition (#89801)

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 which can lead to
crashes or undefined behavior in the program.

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 787a485e0b2f8c..d544cfac55ba36 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5184,6 +5184,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
 
     ParmVarDecl *Parm = Function->getParamDecl(0);
     TypeSourceInfo *NewParmSI = IR.TransformType(Parm->getTypeSourceInfo());
+    assert(NewParmSI && "Type transformation failed.");
     Parm->setType(NewParmSI->getType());
     Parm->setTypeSourceInfo(NewParmSI);
   };


        


More information about the cfe-commits mailing list