Skip to content

Commit 7457228

Browse files
authored
[llvm-nm] Fix heap-use-after-free while executing 'llvm-nm -n --export-symbols' (#65668)
Use symbol's flags saved in `NMSymbol::SymFlags` inside `NMSymbol::isDefined()` since `BasicSymbolRef::getFlags()` requires the symbol's containing entity object to exist (which doesn't, causing llvm-nm to crash).
1 parent 61757fb commit 7457228

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/tools/llvm-nm/llvm-nm.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,8 @@ struct NMSymbol {
237237
std::string IndirectName;
238238

239239
bool isDefined() const {
240-
if (Sym.getRawDataRefImpl().p) {
241-
uint32_t Flags = cantFail(Sym.getFlags());
242-
return !(Flags & SymbolRef::SF_Undefined);
243-
}
240+
if (Sym.getRawDataRefImpl().p)
241+
return !(SymFlags & SymbolRef::SF_Undefined);
244242
return TypeChar != 'U';
245243
}
246244

0 commit comments

Comments
 (0)