summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2008-09-12 13:24:24 +0000
committertobias <tobias@openbsd.org>2008-09-12 13:24:24 +0000
commita37ec391ac4ff0df2a4c0ddd30d8370ef54202ff (patch)
treee897cf593553e675caeb88acdd1046cff32a496b
parent- use shell built-in getopts instead of getopt(1) (diff)
downloadwireguard-openbsd-a37ec391ac4ff0df2a4c0ddd30d8370ef54202ff.tar.xz
wireguard-openbsd-a37ec391ac4ff0df2a4c0ddd30d8370ef54202ff.zip
Plugged two memory leaks which could be encountered while using -r argument
with various CVS commands. "seems to make sense" xsa@
-rw-r--r--usr.bin/cvs/rcs.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 69c28196f4c..a1ff0ff48f8 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.279 2008/09/12 13:11:15 tobias Exp $ */
+/* $OpenBSD: rcs.c,v 1.280 2008/09/12 13:24:24 tobias Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -2645,7 +2645,7 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp)
if (!strcmp(revstr, RCS_HEAD_BRANCH)) {
if (rfp->rf_head == NULL)
- return NULL;
+ return (NULL);
frev = rcsnum_alloc();
rcsnum_cpy(rfp->rf_head, frev, 0);
@@ -2655,11 +2655,8 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp)
/* Possibly we could be passed a version number */
if ((rev = rcsnum_parse(revstr)) != NULL) {
/* Do not return if it is not in RCS file */
- if ((rdp = rcs_findrev(rfp, rev)) != NULL) {
- frev = rcsnum_alloc();
- rcsnum_cpy(rev, frev, 0);
- return (frev);
- }
+ if ((rdp = rcs_findrev(rfp, rev)) != NULL)
+ return (rev);
} else {
/* More likely we will be passed a symbol */
rev = rcs_sym_getrev(rfp, revstr);
@@ -2681,13 +2678,10 @@ rcs_get_revision(const char *revstr, RCSFILE *rfp)
* the minimum of both revision lengths is taken
* instead of just 2.
*/
- if (rfp->rf_head == NULL)
- return NULL;
-
- if (rcsnum_cmp(rev, rfp->rf_head,
+ if (rfp->rf_head == NULL || rcsnum_cmp(rev, rfp->rf_head,
MIN(rfp->rf_head->rn_len, rev->rn_len)) < 0) {
rcsnum_free(rev);
- return NULL;
+ return (NULL);
}
return (rev);
}