diff options
-rw-r--r-- | libdimension/kD_splay_tree.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libdimension/kD_splay_tree.c b/libdimension/kD_splay_tree.c index 9243dbc..1a14e48 100644 --- a/libdimension/kD_splay_tree.c +++ b/libdimension/kD_splay_tree.c @@ -51,10 +51,14 @@ dmnsn_kD_splay_node *dmnsn_kD_splay_copy(dmnsn_kD_splay_node *root) if (root) { node = dmnsn_new_kD_splay_node(); *node = *root; - node->contains = dmnsn_kD_splay_copy(node->contains); - node->container = dmnsn_kD_splay_copy(node->container); - node->contains->parent = node; - node->container->parent = node; + if (node->contains) { + node->contains = dmnsn_kD_splay_copy(node->contains); + node->contains->parent = node; + } + if (node->container) { + node->container = dmnsn_kD_splay_copy(node->container); + node->container->parent = node; + } } return node; } |