From f7a874207297df7ef742506f9faa4697adc82f78 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 20 Feb 2008 18:41:59 +0000 Subject: [PATCH] ebl Fix segfault when freeing an empty htable git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6452 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/lib/htable.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bacula/src/lib/htable.c b/bacula/src/lib/htable.c index d489e3487c..88fd2343ed 100644 --- a/bacula/src/lib/htable.c +++ b/bacula/src/lib/htable.c @@ -193,7 +193,6 @@ bool htable::insert(char *key, void *item) if (lookup(key)) { return false; /* already exists */ } - sm_check(__FILE__, __LINE__, false); ASSERT(index < buckets); Dmsg2(100, "Insert: hash=0x%x index=%d\n", (unsigned)hash, index); hp = (hlink *)(((char *)item)+loffset); @@ -210,7 +209,6 @@ bool htable::insert(char *key, void *item) Dmsg2(100, "num_items=%d max_items=%d\n", num_items, max_items); grow_table(); } - sm_check(__FILE__, __LINE__, false); Dmsg3(100, "Leave insert index=%d num_items=%d key=%s\n", index, num_items, key); return true; } @@ -275,11 +273,12 @@ void htable::destroy() { void *ni; void *li = first(); - do { + + while (li) { ni = next(); free(li); - li = ni; - } while (ni); + li=ni; + } free(table); table = NULL; -- 2.39.5