summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2014-07-09 22:10:16 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2014-07-09 22:10:16 +0000
commita9ec01f2db37121b282526e89404f6411d6f5f32 (patch)
tree7735eebf3cd3acb69bd1d0caa7a96f4e7323093d /usr.sbin/relayd
parente396f6c2989fd4c8bb269acc234961a289fd882a (diff)
Don't assign garbage in kv_extend().
Found by clang.
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/relayd.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c
index c102357a360..e18784c5093 100644
--- a/usr.sbin/relayd/relayd.c
+++ b/usr.sbin/relayd/relayd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.c,v 1.126 2014/07/09 16:42:05 reyk Exp $ */
+/* $OpenBSD: relayd.c,v 1.127 2014/07/09 22:10:15 reyk Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -714,14 +714,14 @@ kv_extend(struct kvlist *keys, char *value)
if ((kv = TAILQ_LAST(keys, kvlist)) == NULL)
return (NULL);
- if (kv->kv_value == NULL) {
- if ((kv->kv_value = strdup(value)) == NULL)
+ if (kv->kv_value != NULL) {
+ if (asprintf(&newvalue, "%s%s", kv->kv_value, value) == -1)
return (NULL);
- } else if (asprintf(&newvalue, "%s%s", kv->kv_value, value) == -1)
- return (NULL);
- free(kv->kv_value);
- kv->kv_value = newvalue;
+ free(kv->kv_value);
+ kv->kv_value = newvalue;
+ } else if ((kv->kv_value = strdup(value)) == NULL)
+ return (NULL);
return (kv);
}