Fix rz_core_analysis_bytes() API use

This commit is contained in:
Anton Kochkov 2024-02-19 20:36:28 +08:00 committed by Anton Kochkov
parent 0c96878500
commit 8574f0b0e4
2 changed files with 12 additions and 15 deletions

View File

@ -722,11 +722,10 @@ PRzAnalysisBytes CutterCore::getRzAnalysisBytesSingle(RVA addr)
rz_io_read_at(core->io, addr, buf, sizeof(buf)); rz_io_read_at(core->io, addr, buf, sizeof(buf));
auto seek = seekTemp(addr); 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<RzAnalysisBytes *>(rz_iterator_next(abiter.get())) : nullptr;
auto ab = vec && rz_pvector_len(vec.get()) > 0
? reinterpret_cast<RzAnalysisBytes *>(rz_pvector_pop_front(vec.get()))
: nullptr;
return { ab, rz_analysis_bytes_free }; return { ab, rz_analysis_bytes_free };
} }
@ -1027,18 +1026,10 @@ RVA CutterCore::nextOpAddr(RVA startAddr, int count)
{ {
CORE_LOCK(); CORE_LOCK();
auto seek = seekTemp(startAddr); auto seek = seekTemp(startAddr);
auto vec = fromOwned(rz_core_analysis_bytes(core, core->offset, core->block, auto consumed =
(int)core->blocksize, count + 1)); rz_core_analysis_ops_size(core, core->offset, core->block, (int)core->blocksize, count);
RVA addr = startAddr + 1; RVA addr = startAddr + consumed;
if (!vec) {
return addr;
}
auto ab = reinterpret_cast<RzAnalysisBytes *>(rz_pvector_tail(vec.get()));
if (!(ab && ab->op)) {
return addr;
}
addr = ab->op->addr;
return addr; return addr;
} }

View File

@ -51,6 +51,12 @@ static inline auto fromOwned(RZ_OWN RzList *data) -> UniquePtrCP<decltype(data),
return { data, {} }; return { data, {} };
} }
static inline auto fromOwned(RZ_OWN RzIterator *data)
-> UniquePtrCP<decltype(data), &rz_iterator_free>
{
return { data, {} };
}
// Rizin list iteration macros // Rizin list iteration macros
// deprecated, prefer using CutterPVector and CutterRzList instead // deprecated, prefer using CutterPVector and CutterRzList instead
#define CutterRzListForeach(list, it, type, x) \ #define CutterRzListForeach(list, it, type, x) \