diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2015-05-30 09:47:26 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2015-05-30 09:47:26 +0000 |
commit | 1dc4f974ddd3716a10977311acbaef0e8e71db86 (patch) | |
tree | f2e22d5bb7069c4d515835a7c225049823ad2ced /usr.sbin | |
parent | 8b2053c0e229799e4a73e67dd83f70c8c9c50620 (diff) |
Plug a memory leak by simplifying kv_free(). By checking the type and
returning early the key and value memory got leaked on HTTP header kvs
since their type was never set.
OK benno@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/relayd/relayd.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index 9e0a3486594..b39956e914a 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.140 2015/05/28 17:08:09 florian Exp $ */ +/* $OpenBSD: relayd.c,v 1.141 2015/05/30 09:47:25 claudio Exp $ */ /* * Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -768,18 +768,13 @@ kv_purge(struct kvtree *keys) void kv_free(struct kv *kv) { - if (kv->kv_type == KEY_TYPE_NONE) - return; - if (kv->kv_key != NULL) { - free(kv->kv_key); - } - kv->kv_key = NULL; - if (kv->kv_value != NULL) { - free(kv->kv_value); - } - kv->kv_value = NULL; - kv->kv_matchtree = NULL; - kv->kv_match = NULL; + /* + * This function does not clear memory referenced by + * kv_children or stuff on the tailqs. Use kv_delete() instead. + */ + + free(kv->kv_key); + free(kv->kv_value); memset(kv, 0, sizeof(*kv)); } |