From c42a74b77cc7374d263ce7ddd3b4e19d9548ae13 Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Mon, 11 Jun 2012 12:04:58 +0000 Subject: [PATCH] - bug #452: fix crash on assert in mesh_state_attachment. git-svn-id: file:///svn/unbound/trunk@2683 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 3 +++ services/mesh.c | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 046a9947d..3f3bfa97a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +11 June 2012: Wouter + - bug #452: fix crash on assert in mesh_state_attachment. + 30 May 2012: Wouter - silence warning from swig-generated code (md set but not used in swig initmodule, due to ifdefs in swig-generated code). diff --git a/services/mesh.c b/services/mesh.c index f6fd288ad..d8ac310ef 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -735,16 +735,20 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub) superref->s = super; subref->node.key = subref; subref->s = sub; -#ifdef UNBOUND_DEBUG - n = -#endif - rbtree_insert(&sub->super_set, &superref->node); - log_assert(n != NULL); + if(!rbtree_insert(&sub->super_set, &superref->node)) { + /* this should not happen, iterator and validator do not + * attach subqueries that are identical. */ + /* already attached, we are done, nothing todo. + * since superref and subref already allocated in region, + * we cannot free them */ + return 1; + } #ifdef UNBOUND_DEBUG n = #endif rbtree_insert(&super->sub_set, &subref->node); - log_assert(n != NULL); + log_assert(n != NULL); /* we checked above if statement, the reverse + administration should not fail now, unless they are out of sync */ return 1; } -- 2.47.3