diff options
| author | Mason Reed <mason@vector35.com> | 2025-02-11 20:19:21 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-02-12 18:43:02 -0500 |
| commit | b453e2587842e548bf61c9aa04a25c0b99e4abda (patch) | |
| tree | 6035b70db769a716eddb6ee7bad3f062c9ef70b7 | |
| parent | cce44e00f23841d3709ac9cd4741ee2482b65595 (diff) | |
[SharedCache] Don't crash if we open a file with slide version 1
Also add some other misc error reporting and nullptr check
| -rw-r--r-- | view/sharedcache/core/SharedCache.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index 642e8bcb..61d0fd4e 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -1063,7 +1063,8 @@ void SharedCache::ParseAndApplySlideInfoForFile(std::shared_ptr<MMappedFileAcces auto slideInfoVersion = file->ReadUInt32(slideInfoOff); if (slideInfoVersion != 2 && slideInfoVersion != 3) { - abort(); + m_logger->LogError("Unsupported slide info version %d", slideInfoVersion); + throw std::runtime_error("Unsupported slide info version"); } MappingInfo map; @@ -1763,9 +1764,17 @@ bool SharedCache::LoadImageWithInstallName(std::string installName, bool skipObj break; } } + + if (!targetImage) + { + m_logger->LogError("Failed to find target image %s", installName.c_str()); + return false; + } + auto it = State().headers.find(targetImage->headerLocation); if (it == State().headers.end()) { + m_logger->LogError("Failed to find target image header %s", installName.c_str()); return false; } const auto& header = it->second; @@ -2693,11 +2702,10 @@ void SharedCache::ReadExportNode(std::vector<Ref<Symbol>>& symbolList, const Sha uint64_t terminalSize = readValidULEB128(current, end); const uint8_t* child = current + terminalSize; if (terminalSize != 0) { - uint64_t imageOffset = 0; uint64_t flags = readValidULEB128(current, end); if (!(flags & EXPORT_SYMBOL_FLAGS_REEXPORT)) { - imageOffset = readValidULEB128(current, end); + uint64_t imageOffset = readValidULEB128(current, end); if (!currentText.empty() && textBase + imageOffset) { uint32_t flags; |
