Skip to content

Commit 1bd6bec

Browse files
committed
Fix various null-derefs.
1 parent d4ef80b commit 1bd6bec

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

librz/arch/analysis.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,12 +1248,17 @@ RZ_API void rz_analysis_purge_imports(RzAnalysis *analysis) {
12481248

12491249
RZ_DEPRECATE RZ_API RZ_BORROW RzAnalysisEsilInterState *rz_analysis_get_esil_inter_state(RZ_NONNULL RzAnalysis *analysis) {
12501250
rz_return_val_if_fail(analysis, NULL);
1251+
if (!analysis->esil) {
1252+
return NULL;
1253+
}
12511254
return analysis->esil->esilinterstate;
12521255
}
12531256

12541257
RZ_DEPRECATE RZ_API void rz_analysis_set_esil_inter_state(RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE RzAnalysisEsilInterState *esilinterstate) {
12551258
rz_return_if_fail(analysis);
1256-
analysis->esil->esilinterstate = esilinterstate;
1259+
if (analysis->esil) {
1260+
analysis->esil->esilinterstate = esilinterstate;
1261+
}
12571262
}
12581263

12591264
RZ_DEPRECATE RZ_API RZ_BORROW RzAnalysisEsil *rz_analysis_get_esil(RZ_NONNULL RzAnalysis *analysis) {

librz/core/cesil.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,9 @@ RZ_API void rz_core_analysis_esil(RzCore *core, ut64 addr, ut64 size, RZ_NULLABL
12351235
bool cfg_analysis_strings = rz_config_get_i(core->config, "analysis.strings");
12361236
bool emu_lazy = rz_config_get_i(core->config, "emu.lazy");
12371237
bool gp_fixed = rz_config_get_i(core->config, "analysis.gpfixed");
1238-
RzAnalysisEsilInterState *estate = rz_analysis_get_esil_inter_state(core->analysis);
12391238
ut64 refptr = 0LL;
12401239
const char *pcname;
1240+
RzAnalysisEsilInterState *estate = NULL;
12411241
RzAnalysisOp op = RZ_EMPTY;
12421242
ut8 *buf = NULL;
12431243
ut64 iend;
@@ -1261,7 +1261,6 @@ RZ_API void rz_core_analysis_esil(RzCore *core, ut64 addr, ut64 size, RZ_NULLABL
12611261
RZ_LOG_ERROR("core: cannot allocate %" PFMT64u "\n", (iend + 2));
12621262
return;
12631263
}
1264-
estate->last_read = UT64_MAX;
12651264
rz_io_read_at_mapped(core->io, start, buf, iend + 1);
12661265
rz_reg_arena_push(rreg);
12671266

@@ -1275,6 +1274,8 @@ RZ_API void rz_core_analysis_esil(RzCore *core, ut64 addr, ut64 size, RZ_NULLABL
12751274
}
12761275
rz_core_analysis_esil_init_mem(core, NULL, UT64_MAX, UT32_MAX);
12771276
}
1277+
estate = rz_analysis_get_esil_inter_state(core->analysis);
1278+
estate->last_read = UT64_MAX;
12781279
const char *spname = rz_reg_get_name(rreg, RZ_REG_NAME_SP);
12791280
EsilBreakCtx ctx = {
12801281
.op = &op,

0 commit comments

Comments
 (0)