From: Christian Grothoff Date: Thu, 8 Apr 2010 12:49:21 +0000 (+0000) Subject: make sure key stays valid for iterator even after entry is removed X-Git-Tag: initial-import-from-subversion-38251~22229 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e8757f03baa17eddef096da91122a282a39e9cb7;p=oweals%2Fgnunet.git make sure key stays valid for iterator even after entry is removed --- diff --git a/src/util/container_multihashmap.c b/src/util/container_multihashmap.c index 7ca6676cb..5b66442cb 100644 --- a/src/util/container_multihashmap.c +++ b/src/util/container_multihashmap.c @@ -194,6 +194,7 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct unsigned int i; struct MapEntry *e; struct MapEntry *n; + GNUNET_HashCode kc; count = 0; for (i = 0; i < map->map_length; i++) @@ -202,8 +203,12 @@ GNUNET_CONTAINER_multihashmap_iterate (const struct while (NULL != (e = n)) { n = e->next; - if ((NULL != it) && (GNUNET_OK != it (it_cls, &e->key, e->value))) - return GNUNET_SYSERR; + if (NULL != it) + { + kc = e->key; + if (GNUNET_OK != it (it_cls, &kc, e->value)) + return GNUNET_SYSERR; + } count++; } } @@ -446,7 +451,7 @@ GNUNET_CONTAINER_multihashmap_get_multiple (const struct n = e->next; if (0 != memcmp (key, &e->key, sizeof (GNUNET_HashCode))) continue; - if ((it != NULL) && (GNUNET_OK != it (it_cls, &e->key, e->value))) + if ((it != NULL) && (GNUNET_OK != it (it_cls, key, e->value))) return GNUNET_SYSERR; count++; }