From 9022edacf64c24db94b217546ec4350bd2472627 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Fri, 12 Sep 2008 13:24:25 +0000 Subject: Plugged two memory leaks which could be encountered while using -r argument with various CVS commands. "seems to make sense" xsa@ --- usr.bin/cvs/rcs.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'usr.bin/cvs/rcs.c') 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 * 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); } -- cgit v1.2.3