From 464cc136939c9b032de032ca4ab62389f3996ee4 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 29 Apr 2025 19:37:38 +0300 Subject: Mitigating NULL pointer return --- c_implementation/src/ak_fs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/c_implementation/src/ak_fs.c b/c_implementation/src/ak_fs.c index 07178bc..148f0ca 100644 --- a/c_implementation/src/ak_fs.c +++ b/c_implementation/src/ak_fs.c @@ -370,7 +370,12 @@ int ak_fs_cfm(akfs_map_v3* map) { sha512sum x; ak_fs_sha512sum_init(&x); - x = *(ak_fs_map_v3_get_root_hash(map)); - ak_fs_cat_file_from_root_hash(&x); - return 0; + sha512sum *rh_ptr = ak_fs_map_v3_get_root_hash(map); + if ( rh_ptr == NULL ) + { + ak_log_debug(__func__, "No root hash found on the map"); + return -1; + } + x = *rh_ptr; + return ak_fs_cat_file_from_root_hash(&x); } -- cgit v1.2.3