From a2805c1a3f5b4362df7fe8ce9318620dbbf4b698 Mon Sep 17 00:00:00 2001 From: lisk77 Date: Thu, 25 Sep 2025 16:43:15 +0200 Subject: [PATCH] fix(cli): tree doesnt try to strdup NULL out of the flat map --- src/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 93df2e4..aef2b96 100644 --- a/src/main.c +++ b/src/main.c @@ -415,6 +415,7 @@ static int commit(int argc, char** argv) { for (size_t idx = 0; idx < files->len; idx++) { BaseFileInfo* base_file = base_file_buffer_search(base_files, files->items[idx]); if (!base_file) { + printf("this is a basefile as it should be\n"); BaseFileInfo info = (BaseFileInfo){.base_num = 0, .diff_num = 0, .name = strdup(files->items[idx])}; base_file_buffer_push(base_files, info); // Compress the files content and put it into the object database @@ -604,8 +605,8 @@ static int commit(int argc, char** argv) { } for (size_t idx = 0; idx < tree->len; idx++) { - ((FileInfo*)tree->items + idx)->hash = strdup(flat_map_get(file_hash_map, ((FileInfo*)tree->items + idx)->name)); - printf("%s: %s\n", ((FileInfo*)tree->items + idx)->name, ((FileInfo*)tree->items + idx)->hash); + char* hash = flat_map_get(file_hash_map, ((FileInfo*)tree->items + idx)->name); + if (hash) ((FileInfo*)tree->items + idx)->hash = strdup(hash); } char tree_hash[41];