From 2e9a08214528b6555815df00eb030fc15a0e16bb Mon Sep 17 00:00:00 2001 From: Rot127 <45763064+Rot127@users.noreply.github.com> Date: Mon, 17 Mar 2025 08:31:53 +0000 Subject: [PATCH] Fix #4098. (#5005) The instructions were found correctly since the search refactor. But the address of the hit was set to the second instruction. This adds the tests discussed in the issue and sets the address of the hit to the first instruction. --- librz/core/casm.c | 2 +- test/db/cmd/cmd_search_a | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/librz/core/casm.c b/librz/core/casm.c index 8580669bdd..a47d66a14e 100644 --- a/librz/core/casm.c +++ b/librz/core/casm.c @@ -442,7 +442,7 @@ RZ_API RzList /**/ *rz_core_asm_strsearch(RzCore *core, const ch RZ_FREE(hits); goto beach; } - hit->addr = addr; + hit->addr = tokcount == 1 ? addr : tidx; hit->len = idx + len - tidx; if (hit->len == -1) { rz_core_asm_hit_free(hit); diff --git a/test/db/cmd/cmd_search_a b/test/db/cmd/cmd_search_a index 4d19849c5e..2b32497018 100644 --- a/test/db/cmd/cmd_search_a +++ b/test/db/cmd/cmd_search_a @@ -97,3 +97,29 @@ EXPECT=<