From 8574f0b0e42a1f0d12599548d9907a56dd236182 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Mon, 19 Feb 2024 20:36:28 +0800 Subject: [PATCH] Fix rz_core_analysis_bytes() API use --- src/core/Cutter.cpp | 21 ++++++--------------- src/core/RizinCpp.h | 6 ++++++ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 47fc607d..2a0db993 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -722,11 +722,10 @@ PRzAnalysisBytes CutterCore::getRzAnalysisBytesSingle(RVA addr) rz_io_read_at(core->io, addr, buf, sizeof(buf)); auto seek = seekTemp(addr); - auto vec = fromOwned(rz_core_analysis_bytes(core, addr, buf, sizeof(buf), 1)); + auto abiter = fromOwned(rz_core_analysis_bytes(core, addr, buf, sizeof(buf), 1)); + auto ab = + abiter ? reinterpret_cast(rz_iterator_next(abiter.get())) : nullptr; - auto ab = vec && rz_pvector_len(vec.get()) > 0 - ? reinterpret_cast(rz_pvector_pop_front(vec.get())) - : nullptr; return { ab, rz_analysis_bytes_free }; } @@ -1027,18 +1026,10 @@ RVA CutterCore::nextOpAddr(RVA startAddr, int count) { CORE_LOCK(); auto seek = seekTemp(startAddr); - auto vec = fromOwned(rz_core_analysis_bytes(core, core->offset, core->block, - (int)core->blocksize, count + 1)); + auto consumed = + rz_core_analysis_ops_size(core, core->offset, core->block, (int)core->blocksize, count); - RVA addr = startAddr + 1; - if (!vec) { - return addr; - } - auto ab = reinterpret_cast(rz_pvector_tail(vec.get())); - if (!(ab && ab->op)) { - return addr; - } - addr = ab->op->addr; + RVA addr = startAddr + consumed; return addr; } diff --git a/src/core/RizinCpp.h b/src/core/RizinCpp.h index 6399e145..65fd95b6 100644 --- a/src/core/RizinCpp.h +++ b/src/core/RizinCpp.h @@ -51,6 +51,12 @@ static inline auto fromOwned(RZ_OWN RzList *data) -> UniquePtrCP UniquePtrCP +{ + return { data, {} }; +} + // Rizin list iteration macros // deprecated, prefer using CutterPVector and CutterRzList instead #define CutterRzListForeach(list, it, type, x) \