summaryrefslogtreecommitdiff
path: root/usr.bin/cvs/rcs.c
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-09-12 13:24:25 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-09-12 13:24:25 +0000
commit9022edacf64c24db94b217546ec4350bd2472627 (patch)
treebcfda9cc6f9b5998b2ea06b868dc6e719c782710 /usr.bin/cvs/rcs.c
parent7b68e225f1a6e7fbe2ee896cf17a46a79b26abab (diff)
Plugged two memory leaks which could be encountered while using -r argument
with various CVS commands. "seems to make sense" xsa@
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-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);
}