From 1a87ce3be5a701f892a145f43328ebc369ea432f Mon Sep 17 00:00:00 2001 From: mquinson Date: Wed, 19 Aug 2009 13:51:22 +0000 Subject: [PATCH] GARGH. Fix a *nasty* long standing bug in dictionaries (many thanks to Cristian) The deal is that strcmp was used regardless of whether the entry was created through the _ext interface or not. So, when you used pointers as key (as we do in gras datadesc for cycle detection for example), the key got truncated on the first \0 (and the rest of it was uninitialized). This is what caused my bug with gras datadesc tests. And it happened only some times because the pointer does not always contain a 0. And it happened more often on 64bits because the pointers are longer and thus have a bigger probability to contain \0. Actually, this bug was already fixed by Cristian on 2008-11-25, but on the mc branch of our private git in Nancy, and never propagated to the trunk. We are still git childrens... git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6605 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- src/xbt/dict_elm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xbt/dict_elm.c b/src/xbt/dict_elm.c index 2284403c83..c1c109628f 100644 --- a/src/xbt/dict_elm.c +++ b/src/xbt/dict_elm.c @@ -32,7 +32,7 @@ xbt_dictelm_t xbt_dictelm_new(const char *key, xbt_dictelm_t element = xbt_mallocator_get(dict_elm_mallocator); element->key = xbt_new(char, key_len + 1); - strncpy(element->key, key, key_len); + memcpy((void *)element->key, (void *)key, key_len); element->key[key_len] = '\0'; element->key_len = key_len; -- 2.20.1