aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2016-09-23 06:33:19 -0300
committerDavid Bremner <david@tethera.net>2016-09-24 10:08:45 -0300
commit514a0a6a3bd74c03db6cd9b28edc0a29a8a2441e (patch)
treef7f3fa9706f92b4fcab2331c2beeef01b5652f38 /lib
parent7b2d7d65126b11ce08079b7cf235e1073fb1c22b (diff)
lib: add talloc reference from string map iterator to map
This is needed so that when the map is modified during traversal, and thus unlinked by the database code, the map is not disposed of until the iterator is done with it.
Diffstat (limited to 'lib')
-rw-r--r--lib/string-map.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/string-map.c b/lib/string-map.c
index 591ff6d5..0bb77e93 100644
--- a/lib/string-map.c
+++ b/lib/string-map.c
@@ -170,6 +170,9 @@ _notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
if (unlikely (iter == NULL))
return NULL;
+ if (unlikely (talloc_reference (iter, map) == NULL))
+ return NULL;
+
iter->key = talloc_strdup (iter, key);
iter->exact = exact;
iter->current = bsearch_first (map->pairs, map->length, key, exact);