diff --git a/libr/anal/anal_ex.c b/libr/anal/anal_ex.c index f35278f8f5..b09e52b30f 100644 --- a/libr/anal/anal_ex.c +++ b/libr/anal/anal_ex.c @@ -110,15 +110,16 @@ R_API void r_anal_ex_clone_op_switch_to_bb (RAnalBlock *bb, RAnalOp *op) { RListIter *iter; RAnalCaseOp *caseop = NULL; - if ( op->switch_op ) { + if (op->switch_op) { bb->switch_op = r_anal_switch_op_new (op->switch_op->addr, op->switch_op->min_val, op->switch_op->max_val); - - r_list_foreach (op->switch_op->cases, iter, caseop) { - r_anal_switch_op_add_case (bb->switch_op, caseop->addr, + if (bb->switch_op){ + r_list_foreach (op->switch_op->cases, iter, caseop) { + r_anal_switch_op_add_case (bb->switch_op, caseop->addr, caseop->value, caseop->jump); + } } } } diff --git a/libr/anal/switch.c b/libr/anal/switch.c index 55cebad07e..a9aa57829c 100644 --- a/libr/anal/switch.c +++ b/libr/anal/switch.c @@ -3,6 +3,7 @@ RAnalSwitchOp *switch_op_new() { RAnalSwitchOp * swop = R_NEW0 (RAnalSwitchOp); + if (!swop) return NULL; swop->cases = r_list_new (); swop->cases->free = (void *)free; swop->min_val = swop->def_val = swop->max_val = 0;