From cb4bce0d0ff376ff1a9aa78fc7a31b894cfbf144 Mon Sep 17 00:00:00 2001 From: astralia Date: Wed, 13 Nov 2024 18:54:16 +0100 Subject: [PATCH] Check diff APIs nullability --- libr/anal/diff.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libr/anal/diff.c b/libr/anal/diff.c index f33074d120..6031e23ed8 100644 --- a/libr/anal/diff.c +++ b/libr/anal/diff.c @@ -43,13 +43,11 @@ R_API void r_anal_diff_setup_i(RAnal *anal, int doops, int thbb, int thfcn) { // Fingerprint function basic block R_API int r_anal_diff_fingerprint_bb(RAnal *anal, RAnalBlock *bb) { + R_RETURN_VAL_IF_FAIL (anal && bb, 0); RAnalOp *op; ut8 *buf; int oplen, idx = 0; - if (!anal) { - return 0; - } if (anal->cur && anal->cur->fingerprint_bb) { return (anal->cur->fingerprint_bb (anal, bb)); } @@ -97,10 +95,11 @@ static int bb_sort_by_addr(const void *x, const void *y) { } R_API size_t r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFunction *fcn) { + R_RETURN_VAL_IF_FAIL (anal && fcn, 0); RAnalBlock *bb; RListIter *iter; - if (anal && anal->cur && anal->cur->fingerprint_fcn) { + if (anal->cur && anal->cur->fingerprint_fcn) { return (anal->cur->fingerprint_fcn (anal, fcn)); } @@ -119,13 +118,11 @@ R_API size_t r_anal_diff_fingerprint_fcn(RAnal *anal, RAnalFunction *fcn) { } R_API bool r_anal_diff_bb(RAnal *anal, RAnalFunction *fcn, RAnalFunction *fcn2) { + R_RETURN_VAL_IF_FAIL (anal && fcn && fcn2, false); RAnalBlock *bb, *bb2, *mbb, *mbb2; RListIter *iter, *iter2; double t, ot; - if (!anal || !fcn || !fcn2) { - return false; - } if (anal->cur && anal->cur->diff_bb) { return (anal->cur->diff_bb (anal, fcn, fcn2)); } @@ -368,9 +365,11 @@ R_API int r_anal_diff_fcn(RAnal *anal, RList *fcns, RList *fcns2) { return true; } +// R2_600 UNUSED R_API int r_anal_diff_eval(RAnal *anal) { - if (anal && anal->cur && anal->cur->diff_eval) { + R_RETURN_VAL_IF_FAIL (anal, false); + if (anal->cur && anal->cur->diff_eval) { return (anal->cur->diff_eval (anal)); } - return true; // XXX: shouldn't this be false? + return false; }