From df6fb4d392e530fbf9d4e331711c500d47980dcc Mon Sep 17 00:00:00 2001 From: Ella Ma Date: Fri, 26 Feb 2021 21:42:23 +0300 Subject: [PATCH] [llvm] Add assertions for the smart pointers with the possibility to be null in DWARFLinker::loadClangModule Split from D91844. The local variable `Unit` in function `DWARFLinker::loadClangModule` in file `llvm/lib/DWARFLinker/DWARFLinker.cpp`. If the variable is not set in the loop below its definition, it will trigger a null pointer dereference after the loop. Patch By: OikawaKirie Reviewed By: avl Differential Revision: https://reviews.llvm.org/D97185 --- llvm/lib/DWARFLinker/DWARFLinker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp index 184c9c8..4846b5c 100644 --- a/llvm/lib/DWARFLinker/DWARFLinker.cpp +++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp @@ -2131,6 +2131,7 @@ Error DWARFLinker::loadClangModule( Unit->markEverythingAsKept(); } } + assert(Unit && "CompileUnit is not set!"); if (!Unit->getOrigUnit().getUnitDIE().hasChildren()) return Error::success(); if (!Quiet && Options.Verbose) { -- 2.7.4