From 19e81ffda5ac22875ef7a5311d3d882f26ada244 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Tue, 15 Feb 2011 15:24:40 +0000 Subject: [PATCH] Sync OpenBSD patchset 859: Free old argument even if setting to NULL. --- arguments.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arguments.c b/arguments.c index f00ab8e8..e184064b 100644 --- a/arguments.c +++ b/arguments.c @@ -1,4 +1,4 @@ -/* $Id: arguments.c,v 1.2 2011-01-07 14:46:57 tcunha Exp $ */ +/* $Id: arguments.c,v 1.3 2011-02-15 15:24:40 tcunha Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott @@ -182,11 +182,12 @@ args_has(struct args *args, u_char ch) void args_set(struct args *args, u_char ch, const char *value) { - if (value != NULL) { - if (args->values[ch] != NULL) - xfree(args->values[ch]); + if (args->values[ch] != NULL) + xfree(args->values[ch]); + if (value != NULL) args->values[ch] = xstrdup(value); - } + else + args->values[ch] = NULL; bit_set(args->flags, ch); }