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/macho/machoview.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'view/macho/machoview.cpp') diff --git a/view/macho/machoview.cpp b/view/macho/machoview.cpp index 7353e995..1c8d8512 100644 --- a/view/macho/machoview.cpp +++ b/view/macho/machoview.cpp @@ -2088,7 +2088,7 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ ParseFunctionStarts(GetDefaultPlatform(), header.textBase, header.functionStarts); } - BeginBulkModifySymbols(); + BulkSymbolModification bulkSymbolModification(this); m_symbolQueue = new SymbolQueue(); try @@ -2105,8 +2105,7 @@ bool MachoView::InitializeHeader(MachOHeader& header, bool isMainHeader, uint64_ m_symbolQueue->Process(); delete m_symbolQueue; m_symbolQueue = nullptr; - - EndBulkModifySymbols(); + bulkSymbolModification.End(); for (auto& relocation : header.rebaseRelocations) { -- cgit v1.3.1