summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorPatrick Latifi <pat@cvs.openbsd.org>2005-05-20 10:40:23 +0000
committerPatrick Latifi <pat@cvs.openbsd.org>2005-05-20 10:40:23 +0000
commitbd206b9485b096efea5d0b3500ad11a7460b66f5 (patch)
tree58a75dddd5213932046c1dff0aa969777fc5381b /usr.bin
parent939bce305b1c66d68fa873a50b6ee6dacb532a62 (diff)
* proper memset
* plug potential memory leak ok jfb
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c
index d926c1e538c..4005bc26c62 100644
--- a/usr.bin/cvs/util.c
+++ b/usr.bin/cvs/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.26 2005/05/20 00:07:19 joris Exp $ */
+/* $OpenBSD: util.c,v 1.27 2005/05/20 10:40:22 pat Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -299,7 +299,7 @@ cvs_getargv(const char *line, char **argv, int argvlen)
char linebuf[256], qbuf[128], *lp, *cp, *arg;
strlcpy(linebuf, line, sizeof(linebuf));
- memset(argv, 0, sizeof(argv));
+ memset(argv, 0, argvlen * sizeof(char *));
argc = 0;
/* build the argument vector */
@@ -374,17 +374,20 @@ cvs_makeargv(const char *line, int *argc)
{
int i, ret;
char *argv[1024], **copy;
+ size_t size;
ret = cvs_getargv(line, argv, 1024);
if (ret == -1)
return (NULL);
- copy = (char **)malloc((ret + 1) * sizeof(char *));
+ size = (ret + 1) * sizeof(char *);
+ copy = (char **)malloc(size);
if (copy == NULL) {
cvs_log(LP_ERRNO, "failed to allocate argument vector");
+ cvs_freeargv(argv, ret);
return (NULL);
}
- memset(copy, 0, sizeof(copy));
+ memset(copy, 0, size);
for (i = 0; i < ret; i++)
copy[i] = argv[i];