Sync OpenBSD patchset 541:

I made a complete horlicks of the last change, fix it so it doesn't either lead
to a double free or free the item after the end of the array.
This commit is contained in:
Tiago Cunha 2009-11-18 01:24:33 +00:00
parent a7158784f2
commit 063a474fe0

View File

@ -1,4 +1,4 @@
/* $Id: cmd-string.c,v 1.25 2009-11-13 16:55:10 tcunha Exp $ */ /* $Id: cmd-string.c,v 1.26 2009-11-18 01:24:33 tcunha Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -151,10 +151,6 @@ cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause)
if (*cmdlist == NULL) if (*cmdlist == NULL)
goto out; goto out;
do
xfree(argv[argc - 1]);
while (--argc > 0);
rval = 0; rval = 0;
goto out; goto out;
case '~': case '~':
@ -189,7 +185,7 @@ out:
if (argv != NULL) { if (argv != NULL) {
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
xfree(argv[argc]); xfree(argv[i]);
xfree(argv); xfree(argv);
} }