From 4412f7ec16743b7d0ee8fc176c101b0124b71a30 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 29 Apr 2025 04:47:19 +0300 Subject: Check for NULL first --- c_implementation/src/ak_fs_mt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/c_implementation/src/ak_fs_mt.c b/c_implementation/src/ak_fs_mt.c index 3f638e6..d083eae 100644 --- a/c_implementation/src/ak_fs_mt.c +++ b/c_implementation/src/ak_fs_mt.c @@ -1,10 +1,15 @@ #include #include #include -#include +#include bool ak_fs_mt_branch_is_null(mt_branch* node) { + if ( node == NULL ) + { + ak_log_warning(__func__, "A NULL mt_branch* node was given"); + return false; + } if ( ak_fs_sha512sum_is_null(&node->root) && ak_fs_sha512sum_is_null(&node->head) && @@ -18,6 +23,11 @@ bool ak_fs_mt_branch_is_null(mt_branch* node) bool ak_fs_mt_branch_compare(mt_branch *a, mt_branch *b) { + if ( a == NULL || b == NULL ) + { + ak_log_warning(__func__, "One or two NULL mt_branch* node was given"); + return false; + } if ( ak_fs_sha512sum_compare(&a->root, &b->root) && ak_fs_sha512sum_compare(&a->head, &b->head) && -- cgit v1.2.3