changeset 2217:8483c685cf03

Allow tern_foreach on an empty (NULL) ternary tree
author Michael Pavone <pavone@retrodev.com>
date Tue, 30 Aug 2022 18:43:08 -0700
parents 4e27c36f947c
children 58774a77f2e0
files tern.c
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tern.c	Tue Aug 30 18:42:45 2022 -0700
+++ b/tern.c	Tue Aug 30 18:43:08 2022 -0700
@@ -286,6 +286,9 @@
 
 void tern_foreach(tern_node *head, iter_fun fun, void *data)
 {
+	if (!head) {
+		return;
+	}
 	//lame, but good enough for my purposes
 	char key[MAX_ITER_KEY+1];
 	tern_foreach_int(head, fun, data, key, 0);