Fix null pointer dereference when a file is not an object file

This commit is contained in:
bjorn3 2024-08-14 19:37:14 +00:00
parent 7c972d75dc
commit 901c9daa05

View File

@ -80,6 +80,9 @@ LLVMRustGetSymbols(char *BufPtr, size_t BufLen, void *State,
return ErrorCallback(toString(ObjOrErr.takeError()).c_str()); return ErrorCallback(toString(ObjOrErr.takeError()).c_str());
} }
std::unique_ptr<object::SymbolicFile> Obj = std::move(*ObjOrErr); std::unique_ptr<object::SymbolicFile> Obj = std::move(*ObjOrErr);
if (Obj == nullptr) {
return 0;
}
for (const object::BasicSymbolRef &S : Obj->symbols()) { for (const object::BasicSymbolRef &S : Obj->symbols()) {
if (!isArchiveSymbol(S)) if (!isArchiveSymbol(S))