From 67ebbc00442335b3f92177183bbbbb4574e35bf0 Mon Sep 17 00:00:00 2001 From: mquinson Date: Fri, 16 Oct 2009 09:06:55 +0000 Subject: [PATCH] Fix a vicious bug in dictionaries inducing that some elements were not freed on xbt_dict_free() git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6799 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- ChangeLog | 2 ++ src/xbt/dict.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d90ded4ba1..65499d7e71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -111,6 +111,8 @@ SimGrid (3.3.4) unstable; urgency=low Introduce a MSG_TIMEOUT_FAILURE return code and use it consistently. * Integrate patch #8636: Obey DESTDIR when installing documentation. Thanks to Robson Peixoto. + * Fix a vicious bug in dictionaries inducing that some elements were + not freed on xbt_dict_free() -- Da SimGrid team diff --git a/src/xbt/dict.c b/src/xbt/dict.c index d81b96bac3..1ef05f0613 100644 --- a/src/xbt/dict.c +++ b/src/xbt/dict.c @@ -80,7 +80,9 @@ void xbt_dict_free(xbt_dict_t * dict) if (dict != NULL && *dict != NULL) { table_size = (*dict)->table_size; table = (*dict)->table; - for (i = 0; (*dict)->count && i < table_size; i++) { + /* Warning: the size of the table is 'table_size+1'... + * This is because table_size is used as a binary mask in xbt_dict_rehash */ + for (i = 0; (*dict)->count && i <= table_size; i++) { current = table[i]; while (current != NULL) { previous = current; -- 2.20.1