From 540fca65afaff35343a938b86596b21f2e16b48d Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Fri, 28 Nov 2025 11:13:08 -0800 Subject: 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. --- view/kernelcache/core/MachOProcessor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'view/kernelcache/core/MachOProcessor.cpp') diff --git a/view/kernelcache/core/MachOProcessor.cpp b/view/kernelcache/core/MachOProcessor.cpp index fb3d2b27..5731d80e 100644 --- a/view/kernelcache/core/MachOProcessor.cpp +++ b/view/kernelcache/core/MachOProcessor.cpp @@ -50,7 +50,7 @@ void KernelCacheMachOProcessor::ApplyHeader(const KernelCache& cache, KernelCach m_view->AddFunctionForAnalysis(targetPlatform, func, false); } - m_view->BeginBulkModifySymbols(); + BulkSymbolModification bulkSymbolModification(m_view); // Apply symbols from symbol table. if (header.symtab.symoff != 0) @@ -78,7 +78,6 @@ void KernelCacheMachOProcessor::ApplyHeader(const KernelCache& cache, KernelCach ApplySymbol(m_view, typeLib, symbol, symbolType); } } - m_view->EndBulkModifySymbols(); } uint64_t KernelCacheMachOProcessor::ApplyHeaderSections(KernelCacheMachOHeader& header) -- cgit v1.3.1