summaryrefslogtreecommitdiff
path: root/lib/fstree
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-25 14:49:52 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-03-25 14:49:52 +0100
commitb0f6ab7ff26c1152ee4894a86f69b183cfabe94f (patch)
tree379eab9d6e618db114b67319aafd04339c6f0aed /lib/fstree
parent62a3a2e1ab14ca97a91376a6cc99be63c05db480 (diff)
libfstree: add an assertion that root is not NULL
If the path argument is "", we assume that referes to root and set the *existing* target node to the root node and skip ahead across the tree search. This leaves "name" uninitialized, which makes coverity panic, because fs->root could be NULL, going down the wrong path. Obviously, this should never, *ever* happen and there is no reasonable recovery strategy if it suddenly does, so simply add an assertion. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree')
-rw-r--r--lib/fstree/add_by_path.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/fstree/add_by_path.c b/lib/fstree/add_by_path.c
index 8918efc..0afd898 100644
--- a/lib/fstree/add_by_path.c
+++ b/lib/fstree/add_by_path.c
@@ -9,6 +9,7 @@
#include "fstree.h"
#include <string.h>
+#include <assert.h>
#include <errno.h>
tree_node_t *fstree_add_generic(fstree_t *fs, const char *path,
@@ -19,6 +20,7 @@ tree_node_t *fstree_add_generic(fstree_t *fs, const char *path,
if (*path == '\0') {
child = fs->root;
+ assert(child != NULL);
goto out;
}