summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2006-03-19 18:43:56 +0000
committerotto <otto@openbsd.org>2006-03-19 18:43:56 +0000
commit98b17e933ae760db6a0611c78b32f6c8e954f44d (patch)
tree75a7ee1ea7a8615d2a605595e3abdb7e6b8b9bb1
parentsis950 has 0x5b missing, so it looks more like an it8712f-a (diff)
downloadwireguard-openbsd-98b17e933ae760db6a0611c78b32f6c8e954f44d.tar.xz
wireguard-openbsd-98b17e933ae760db6a0611c78b32f6c8e954f44d.zip
Fix mem leaks in error path. From NetBSD's coverity analysis. ok pat@
deraadt@
-rw-r--r--sbin/init/init.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index 1570981050c..5dfdb03b725 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.37 2005/11/12 13:30:46 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.38 2006/03/19 18:43:56 otto Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.37 2005/11/12 13:30:46 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.38 2006/03/19 18:43:56 otto Exp $";
#endif
#endif /* not lint */
@@ -825,8 +825,13 @@ construct_argv(char *command)
sizeof (char *));
static const char separators[] = " \t";
- if ((argv[argc++] = strtok(command, separators)) == 0)
+ if (argv == NULL)
return (0);
+
+ if ((argv[argc++] = strtok(command, separators)) == 0) {
+ free(argv);
+ return (0);
+ }
while ((argv[argc++] = strtok(NULL, separators)))
continue;
return (argv);