diff options
| author | Mark Rowe <mark@vector35.com> | 2025-11-28 11:13:08 -0800 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-12-08 13:21:58 -0800 |
| commit | 540fca65afaff35343a938b86596b21f2e16b48d (patch) | |
| tree | f84da14232124ab1829f4051de2794b304355827 /view/sharedcache/core/MachOProcessor.cpp | |
| parent | daede114cfacf4cd68ed0a9f67c829b8b16da961 (diff) | |
Introduce an RAII type for managing bulk symbol modifications
Fixes https://github.com/Vector35/binaryninja-api/issues/7666.
Correctly managing the state of bulk symbol modifications via
`BeginBulkModifySymbols` / `EndBulkModifySymbols` is error-prone in the
face of exceptions and early returns. Leaking a bulk symbol modification
can leave the view in a state where no further changes to symbols will
be applied.
All users of the C++ API are encouraged to move from
`BeginBulkModifySymbols` / `EndBulkModifySymbols` to the new
`BulkSymbolModification` class.
Diffstat (limited to 'view/sharedcache/core/MachOProcessor.cpp')
| -rw-r--r-- | view/sharedcache/core/MachOProcessor.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/view/sharedcache/core/MachOProcessor.cpp b/view/sharedcache/core/MachOProcessor.cpp index 281f40c2..31fdbe6c 100644 --- a/view/sharedcache/core/MachOProcessor.cpp +++ b/view/sharedcache/core/MachOProcessor.cpp @@ -52,7 +52,7 @@ void SharedCacheMachOProcessor::ApplyHeader(const SharedCache& cache, SharedCach m_view->AddFunctionForAnalysis(targetPlatform, func, false); } - m_view->BeginBulkModifySymbols(); + BulkSymbolModification bulkSymbolModification(m_view); // Apply symbols from symbol table. if (header.symtab.symoff != 0) @@ -80,7 +80,6 @@ void SharedCacheMachOProcessor::ApplyHeader(const SharedCache& cache, SharedCach ApplySymbol(m_view, typeLib, symbol, symbolType); } } - m_view->EndBulkModifySymbols(); } // Apply symbols from the .symbols cache files. @@ -127,14 +126,13 @@ void SharedCacheMachOProcessor::ApplyUnmappedLocalSymbols(const SharedCache& cac uint64_t symbolTableStart = localSymbolsAddr + (localSymbolsEntry.nlistStartIndex * sizeof(nlist_64)); TableInfo symbolInfo = {symbolTableStart, localSymbolsEntry.nlistCount}; TableInfo stringInfo = {localStringsAddr, localSymbolsInfo.stringsSize}; - m_view->BeginBulkModifySymbols(); + BulkSymbolModification bulkSymbolModification(m_view); const auto symbols = header.ReadSymbolTable(*localSymbolsVM, symbolInfo, stringInfo); for (const auto &sym: symbols) { auto [symbol, symbolType] = sym.GetBNSymbolAndType(*m_view); ApplySymbol(m_view, typeLib, std::move(symbol), std::move(symbolType)); } - m_view->EndBulkModifySymbols(); return; } } |
