summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2006-03-19 18:43:57 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2006-03-19 18:43:57 +0000
commitcf26df33d3d4b274e890d6ca0ea8cc6c69b38ee1 (patch)
tree90f93f332683f0342316901b921795f93b79fbae
parent163a03ff2bebf7f64259dc6f20aade64f4d63d2e (diff)
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);