From b9da7a9eda942fb79f15fff927e6bc01ffae6675 Mon Sep 17 00:00:00 2001 From: billow Date: Wed, 1 May 2024 15:36:32 +0800 Subject: [PATCH] fix --- librz/arch/il/analysis_il.c | 14 +++++++------- librz/il/il_vm_eval.c | 5 ++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/librz/arch/il/analysis_il.c b/librz/arch/il/analysis_il.c index f0e842041a4..893b597d5c2 100644 --- a/librz/arch/il/analysis_il.c +++ b/librz/arch/il/analysis_il.c @@ -230,17 +230,18 @@ RZ_API bool rz_analysis_il_vm_sync_to_reg(RzAnalysisILVM *vm, RZ_NONNULL RzReg * static void il_events(RzILVM *vm, RzStrBuf *sb) { void **it; - RzILEvent *evt; rz_pvector_foreach (vm->events, it) { - evt = *it; + RzILEvent *evt = *it; rz_il_event_stringify(evt, sb); rz_strbuf_append(sb, "\n"); } } +typedef bool (*cond_callback)(RzAnalysisILVM *vm, void *user); + static RzAnalysisILStepResult analysis_il_vm_step_while( RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg, - bool with_events, bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) { + bool with_events, RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) { rz_return_val_if_fail(analysis && vm, false); RzAnalysisPlugin *cur = analysis->cur; @@ -253,9 +254,8 @@ static RzAnalysisILStepResult analysis_il_vm_step_while( } RzAnalysisILStepResult res = RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS; - ut64 addr = 0; while (cond(vm, user)) { - addr = rz_bv_to_ut64(vm->vm->pc); + ut64 addr = rz_bv_to_ut64(vm->vm->pc); ut8 code[32] = { 0 }; analysis->read_at(analysis, addr, code, sizeof(code)); RzAnalysisOp op = { 0 }; @@ -318,7 +318,7 @@ static RzAnalysisILStepResult analysis_il_vm_step_while( */ RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while( RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg, - bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) { + RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) { return analysis_il_vm_step_while(analysis, vm, reg, false, cond, user); } @@ -342,7 +342,7 @@ RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while( */ RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step_while_with_events( RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg, - bool (*cond)(RzAnalysisILVM *vm, void *user), void *user) { + RZ_NONNULL cond_callback cond, RZ_NULLABLE void *user) { return analysis_il_vm_step_while(analysis, vm, reg, true, cond, user); } diff --git a/librz/il/il_vm_eval.c b/librz/il/il_vm_eval.c index 8e83988c084..901f9b14330 100644 --- a/librz/il/il_vm_eval.c +++ b/librz/il/il_vm_eval.c @@ -263,11 +263,10 @@ RZ_API void rz_il_vm_mem_storew(RzILVM *vm, RzILMemIndex index, RzBitVector *key RzBitVector *old_value = rz_il_mem_loadw(mem, key, rz_bv_len(value), vm->big_endian); if (!rz_il_mem_storew(mem, key, value, vm->big_endian)) { RZ_LOG_ERROR("StoreW mem %u 0x%llx failed\n", (unsigned int)index, rz_bv_to_ut64(key)); - return; + goto end; } - RzBitVector *new_value = rz_il_mem_loadw(mem, key, rz_bv_len(value), vm->big_endian); - assert(rz_bv_eq(new_value, value)); rz_il_vm_event_add(vm, rz_il_event_mem_write_new(key, old_value, value)); +end: rz_bv_free(old_value); }