From 1e247511e54767667a0a9ac0c06f3206beb005af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolai=20H=C3=A4hnle?= Date: Sat, 26 Aug 2017 03:06:09 +0200 Subject: [PATCH] util/ralloc: set prev-pointers correctly in ralloc_adopt Found by inspection. I'm not aware of any actual failures caused by this, but a precise sequence of ralloc_adopt and ralloc_free should be able to cause problems. v2: make the code slightly clearer (Eric) Reviewed-by: Eric Engestrom --- src/util/ralloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/ralloc.c b/src/util/ralloc.c index bf46439..566f08a 100644 --- a/src/util/ralloc.c +++ b/src/util/ralloc.c @@ -311,10 +311,12 @@ ralloc_adopt(const void *new_ctx, void *old_ctx) for (child = old_info->child; child->next != NULL; child = child->next) { child->parent = new_info; } + child->parent = new_info; /* Connect the two lists together; parent them to new_ctx; make old_ctx empty. */ child->next = new_info->child; - child->parent = new_info; + if (child->next) + child->next->prev = child; new_info->child = old_info->child; old_info->child = NULL; } -- 2.7.4