summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-17 16:09:04 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-02-17 16:09:04 +0000
commit2b3b909c44c7e9a21d2f42704511922dc2297eee (patch)
treee7787661a5e0a8ec7efb5a93427072a8cf6344f8 /usr.bin
parent49e7b155f3ff9aced552d9857895e62552fe1192 (diff)
only increase the reference count on the cvsroot structure when it
gets inserted into the cache. This makes cvsroot_free() work correctly instead of leaking memory in error cases of cvsroot_parse() spotted by and ok pat@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/root.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c
index fcc2594e686..de43073d501 100644
--- a/usr.bin/cvs/root.c
+++ b/usr.bin/cvs/root.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: root.c,v 1.14 2004/12/28 21:58:42 jfb Exp $ */
+/* $OpenBSD: root.c,v 1.15 2005/02/17 16:09:03 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -102,7 +102,7 @@ cvsroot_parse(const char *str)
return (NULL);
}
memset(root, 0, sizeof(*root));
- root->cr_ref = 2;
+ root->cr_ref = 1;
root->cr_method = CVS_METHOD_NONE;
CVS_RSTVR(root);
@@ -215,12 +215,10 @@ cvsroot_parse(const char *str)
/* add to the cache */
tmp = realloc(cvs_rcache, (cvs_rcsz + 1) * sizeof(struct cvsroot *));
- if (tmp == NULL) {
- /* just forget about the cache and return anyways */
- root->cr_ref--;
- } else {
+ if (tmp != NULL) {
cvs_rcache = (struct cvsroot **)tmp;
cvs_rcache[cvs_rcsz++] = root;
+ root->cr_ref++;
}
return (root);