From 29e8668e510ba042ec2c076f269b914e7c7d173f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Felipe=20Melchor?= Date: Thu, 21 May 2015 21:30:28 +0200 Subject: [PATCH] Fix a NULL dereference --- libr/anal/anal_ex.c | 9 +++++---- libr/anal/switch.c | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) 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;