From 230b3145d0536ff3839d85c618345ad5717e0191 Mon Sep 17 00:00:00 2001 From: claudio Date: Sat, 30 May 2015 09:47:25 +0000 Subject: [PATCH] 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@ --- usr.sbin/relayd/relayd.c | 21 ++++++++------------- 1 file 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 @@ -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)); } -- 2.20.1