From 4d21684f61cd19dfd441eac10b2a61bbf32e20eb Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 11 Jan 2007 09:42:59 +0000 Subject: [PATCH] Duplicate fix of Kevin Lyles's bug from r7092. git-svn-id: svn://svn.tartarus.org/sgt/library@7094 cda61777-01e9-0310-a592-d414129be87e --- tree234.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tree234.c b/tree234.c index bc88039..257c978 100644 --- a/tree234.c +++ b/tree234.c @@ -1440,8 +1440,11 @@ tree234 *copytree234(tree234 *t, copyfn234 copyfn, void *copyfnstate) { tree234 *t2; t2 = newtree234(t->cmp); - t2->root = copynode234(t->root, copyfn, copyfnstate); - t2->root->parent = NULL; + if (t->root) { + t2->root = copynode234(t->root, copyfn, copyfnstate); + t2->root->parent = NULL; + } else + t2->root = NULL; return t2; } @@ -2122,11 +2125,12 @@ int main(void) { tree = newtree234(mycmp); cmp = mycmp; arraylen = 0; - for (i = 0; i < 16; i++) { - addtest(strings[i]); + for (i = 0; i < 17; i++) { tree2 = copytree234(tree, NULL, NULL); splittest(tree2, array, arraylen); freetree234(tree2); + if (i < 16) + addtest(strings[i]); } freetree234(tree); -- 2.11.0