summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Latifi <pat@cvs.openbsd.org>2004-11-28 15:12:18 +0000
committerPatrick Latifi <pat@cvs.openbsd.org>2004-11-28 15:12:18 +0000
commitc6bb5516772f641d8c7cdc213f9c7712ea5a33c0 (patch)
tree82fc68bd84af8a4d48f3a54040527e2ef47f1bc4
parentb4083bdd9e35a8a9ff1611292ce4b3e9c2cce55e (diff)
make sure va_end() is always called in all possible paths
ok jfb
-rw-r--r--usr.bin/cvs/buf.c6
-rw-r--r--usr.bin/cvs/conf.y8
-rw-r--r--usr.bin/cvs/cvsd.c12
-rw-r--r--usr.bin/cvs/log.c4
4 files changed, 15 insertions, 15 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 33b503d2014..016ef2977b5 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.3 2004/09/27 13:29:27 joris Exp $ */
+/* $OpenBSD: buf.c,v 1.4 2004/11/28 15:12:17 pat Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -341,13 +341,13 @@ cvs_buf_fappend(BUF *b, const char *fmt, ...)
va_list vap;
va_start(vap, fmt);
-
ret = vasprintf(&str, fmt, vap);
+ va_end(vap);
+
if (ret == -1) {
cvs_log(LP_ERRNO, "failed to format data");
return (-1);
}
- va_end(vap);
ret = cvs_buf_append(b, str, ret);
free(str);
diff --git a/usr.bin/cvs/conf.y b/usr.bin/cvs/conf.y
index 57cb242cf2f..54bd91070a0 100644
--- a/usr.bin/cvs/conf.y
+++ b/usr.bin/cvs/conf.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.y,v 1.4 2004/11/26 16:23:50 jfb Exp $ */
+/* $OpenBSD: conf.y,v 1.5 2004/11/28 15:12:17 pat Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -504,16 +504,16 @@ yyerror(const char *fmt, ...)
char *nfmt;
va_list vap;
- va_start(vap, fmt);
-
if (asprintf(&nfmt, "%s:%d: %s", conf_file, yylval.lineno, fmt) == -1) {
cvs_log(LP_ERRNO, "failed to allocate message buffer");
return (-1);
}
+
+ va_start(vap, fmt);
cvs_vlog(LP_ERR, nfmt, vap);
+ va_end(vap);
free(nfmt);
- va_end(vap);
return (0);
}
diff --git a/usr.bin/cvs/cvsd.c b/usr.bin/cvs/cvsd.c
index bb8ff02f332..7a8ebd69734 100644
--- a/usr.bin/cvs/cvsd.c
+++ b/usr.bin/cvs/cvsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvsd.c,v 1.11 2004/11/25 18:30:12 jfb Exp $ */
+/* $OpenBSD: cvsd.c,v 1.12 2004/11/28 15:12:17 pat Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -860,6 +860,7 @@ int
cvsd_set(int what, ...)
{
char *str;
+ int error = 0;
va_list vap;
str = NULL;
@@ -872,6 +873,7 @@ cvsd_set(int what, ...)
str = strdup(va_arg(vap, char *));
if (str == NULL) {
cvs_log(LP_ERRNO, "failed to set string");
+ va_end(vap);
return (-1);
}
}
@@ -886,8 +888,7 @@ cvsd_set(int what, ...)
if (cvsd_sock_path != NULL)
free(cvsd_sock_path);
cvsd_sock_path = str;
- if (cvsd_sock_open() < 0)
- return (-1);
+ error = cvsd_sock_open();
break;
case CVSD_SET_USER:
if (cvsd_user != NULL)
@@ -917,12 +918,13 @@ cvsd_set(int what, ...)
break;
default:
cvs_log(LP_ERR, "invalid field to set");
- return (-1);
+ error = -1;
+ break;
}
va_end(vap);
- return (0);
+ return (error);
}
diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c
index a2dec0a2af8..a5d19d7bcba 100644
--- a/usr.bin/cvs/log.c
+++ b/usr.bin/cvs/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.4 2004/08/05 13:39:01 jfb Exp $ */
+/* $OpenBSD: log.c,v 1.5 2004/11/28 15:12:17 pat Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -295,9 +295,7 @@ cvs_printf(const char *fmt, ...)
va_list vap;
va_start(vap, fmt);
-
ret = vprintf(fmt, vap);
-
va_end(vap);
return (ret);