[lldb][FreeBSDKernel] Add missing error checks in DynamicLoader#189250
Merged
[lldb][FreeBSDKernel] Add missing error checks in DynamicLoader#189250
Conversation
Member
|
@llvm/pr-subscribers-lldb Author: Minsoo Choo (mchoo7) ChangesAdd extra guards in case a call to function fails. For example, the result of Full diff: https://github.com/llvm/llvm-project/pull/189250.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
index 00b1de6aee369..c2329f17b339d 100644
--- a/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
+++ b/lldb/source/Plugins/DynamicLoader/FreeBSD-Kernel/DynamicLoaderFreeBSDKernel.cpp
@@ -162,7 +162,7 @@ bool DynamicLoaderFreeBSDKernel::ReadELFHeader(Process *process,
*read_error = false;
if (process->ReadMemory(addr, &header, sizeof(header), error) !=
- sizeof(header)) {
+ sizeof(header) || error.Fail()) {
if (read_error)
*read_error = true;
return false;
@@ -291,7 +291,7 @@ bool DynamicLoaderFreeBSDKernel::KModImageInfo::ReadMemoryModule(
llvm::ELF::Elf64_Ehdr elf_eheader;
Status error;
if (process->ReadMemory(m_load_address, &elf_eheader, sizeof(elf_eheader),
- error) == sizeof(elf_eheader))
+ error) == sizeof(elf_eheader) && error.Success())
size_to_read = sizeof(llvm::ELF::Elf64_Ehdr) +
elf_eheader.e_phnum * elf_eheader.e_phentsize;
}
@@ -358,7 +358,7 @@ bool DynamicLoaderFreeBSDKernel::KModImageInfo::LoadImageUsingMemoryModule(
if (IsKernel()) {
Status error;
if (PluginManager::DownloadObjectAndSymbolFile(module_spec, error,
- true)) {
+ true) && error.Success()) {
if (FileSystem::Instance().Exists(module_spec.GetFileSpec()))
m_module_sp = std::make_shared<Module>(module_spec.GetFileSpec(),
target.GetArchitecture());
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add extra guards in case a call to function fails. For example, the result of
ReadMemory()cannot be trusted whenerror.Fail()is true, and this change ensures the code executes properly according to the value of the error.