diff options
author | kaotisk <kaotisk@arching-kaos.org> | 2025-04-29 04:47:19 +0300 |
---|---|---|
committer | kaotisk <kaotisk@arching-kaos.org> | 2025-04-29 04:47:19 +0300 |
commit | 4412f7ec16743b7d0ee8fc176c101b0124b71a30 (patch) | |
tree | 227c261ef394d6f9d5dad47b04e431c1a69962f8 | |
parent | 1d6d2360e37107d93b81343e802cb736cbfd7847 (diff) | |
download | arching-kaos-tools-4412f7ec16743b7d0ee8fc176c101b0124b71a30.tar.gz arching-kaos-tools-4412f7ec16743b7d0ee8fc176c101b0124b71a30.tar.bz2 arching-kaos-tools-4412f7ec16743b7d0ee8fc176c101b0124b71a30.zip |
Check for NULL first
-rw-r--r-- | c_implementation/src/ak_fs_mt.c | 12 |
1 files changed, 11 insertions, 1 deletions
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 <stdio.h> #include <libakfs.h> #include <libaklog.h> -#include <stdlib.h> +#include <stdbool.h> 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) && |