X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/2d56b16ff20a3ca254f6058222e15595c5094652..f70a606ea75cc1d03d335b3da1122f4cd7d0e381:/tree234.c?ds=inline diff --git a/tree234.c b/tree234.c index 8101c78b..f97837a1 100644 --- a/tree234.c +++ b/tree234.c @@ -569,6 +569,17 @@ void del234(tree234 *t, void *e) { } n->elems[j] = NULL; n->kids[j+1] = NULL; + /* + * It's possible, in this case, that we've just removed + * the only element in the root of the tree. If so, + * shift the root. + */ + if (n->elems[0] == NULL) { + LOG((" shifting root!\n")); + t->root = a; + a->parent = NULL; + sfree(n); + } /* * Now go round the deletion process again, with n * pointing at the new big node and e still the same.