ircd: Fix capability entry name string ownership.

The entry->cap must be copied and exclusive to the entry for the
cap to be orphaned, even if literals are expected. Because modules.
This commit is contained in:
Jason Volk 2016-06-21 17:32:28 -07:00
parent 2e29fd422d
commit 94afbe9c8e

View file

@ -71,7 +71,7 @@ capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata)
} }
entry = rb_malloc(sizeof(struct CapabilityEntry)); entry = rb_malloc(sizeof(struct CapabilityEntry));
entry->cap = cap; entry->cap = rb_strdup(cap);
entry->flags = 0; entry->flags = 0;
entry->value = idx->highest_bit; entry->value = idx->highest_bit;
entry->ownerdata = ownerdata; entry->ownerdata = ownerdata;
@ -133,7 +133,9 @@ capability_destroy(rb_dictionary_element *delem, void *privdata)
{ {
s_assert(delem != NULL); s_assert(delem != NULL);
rb_free(delem->data); struct CapabilityEntry *entry = delem->data;
rb_free((char *)entry->cap);
rb_free(entry);
} }
struct CapabilityIndex * struct CapabilityIndex *