From f59795b2b703d5a782e4c29c0e786ee01942f16a Mon Sep 17 00:00:00 2001 From: "Manna, Soumi" Date: Sat, 27 May 2023 07:15:24 -0700 Subject: [NFC][CLANG] Fix nullptr dereference issue in CodeGenModule::GetConstantArrayFromStringLiteral() This patch adds an assert. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151480 --- clang/lib/CodeGen/CodeGenModule.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d2a28b66cac9..49b670487749 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5888,6 +5888,7 @@ CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) { // Resize the string to the right size, which is indicated by its type. const ConstantArrayType *CAT = Context.getAsConstantArrayType(E->getType()); + assert(CAT && "String literal not of constant array type!"); Str.resize(CAT->getSize().getZExtValue()); return llvm::ConstantDataArray::getString(VMContext, Str, false); } -- cgit v1.2.3