From 94afbe9c8e423280d28e4ab296d868c8a42c0bc6 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 21 Jun 2016 17:32:28 -0700 Subject: [PATCH] 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. --- ircd/capability.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ircd/capability.c b/ircd/capability.c index 618c127a..f82821d9 100644 --- a/ircd/capability.c +++ b/ircd/capability.c @@ -71,7 +71,7 @@ capability_put(struct CapabilityIndex *idx, const char *cap, void *ownerdata) } entry = rb_malloc(sizeof(struct CapabilityEntry)); - entry->cap = cap; + entry->cap = rb_strdup(cap); entry->flags = 0; entry->value = idx->highest_bit; entry->ownerdata = ownerdata; @@ -133,7 +133,9 @@ capability_destroy(rb_dictionary_element *delem, void *privdata) { s_assert(delem != NULL); - rb_free(delem->data); + struct CapabilityEntry *entry = delem->data; + rb_free((char *)entry->cap); + rb_free(entry); } struct CapabilityIndex *