summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-12-16 18:55:53 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-12-16 18:55:53 +0000
commit419b1510034f2eb96ca9d5da1005bb39ac015204 (patch)
treeba2bfd0878b69e61f7cdae0d658671dc1956dd93 /usr.bin/cvs
parent13c1cb9b7af96bbfafa2bd70425a37d0114c9e70 (diff)
plug some memory leaks on error cases
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/rcs.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c
index 7dc2ddcf7f8..b6e8bb73c97 100644
--- a/usr.bin/cvs/rcs.c
+++ b/usr.bin/cvs/rcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcs.c,v 1.16 2004/12/16 17:16:18 jfb Exp $ */
+/* $OpenBSD: rcs.c,v 1.17 2004/12/16 18:55:52 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -381,6 +381,8 @@ rcs_addsym(RCSFILE *rfp, const char *sym, RCSNUM *snum)
/* first look for duplication */
TAILQ_FOREACH(symp, &(rfp->rf_symbols), rs_list) {
if (strcmp(symp->rs_name, sym) == 0) {
+ cvs_log(LP_ERR, "attempt to add duplicate symbol `%s'",
+ sym);
return (-1);
}
}
@@ -400,6 +402,7 @@ rcs_addsym(RCSFILE *rfp, const char *sym, RCSNUM *snum)
symp->rs_num = rcsnum_alloc();
if (symp->rs_num == NULL) {
+ free(symp->rs_name);
free(symp);
return (-1);
}
@@ -437,16 +440,20 @@ rcs_patch(const char *data, const char *patch)
return (NULL);
dlines = rcs_splitlines(data);
- if (dlines == NULL)
+ if (dlines == NULL) {
+ cvs_buf_free(res);
return (NULL);
+ }
plines = rcs_splitlines(patch);
if (plines == NULL) {
+ cvs_buf_free(res);
rcs_freefoo(dlines);
return (NULL);
}
if (rcs_patch_lines(dlines, plines) < 0) {
+ cvs_buf_free(res);
rcs_freefoo(plines);
rcs_freefoo(dlines);
return (NULL);
@@ -598,14 +605,19 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *rev)
* This will need some rework to support sub branches.
*/
crev = rcsnum_alloc();
- if (crev == NULL)
+ if (crev == NULL) {
+ cvs_buf_free(rbuf);
return (NULL);
+ }
rcsnum_cpy(rfp->rf_head, crev, 0);
do {
crev->rn_id[crev->rn_len - 1]--;
rdp = rcs_findrev(rfp, crev);
- if (rdp == NULL)
+ if (rdp == NULL) {
+ rcsnum_free(crev);
+ cvs_buf_free(rbuf);
return (NULL);
+ }
cvs_buf_putc(rbuf, '\0');
bp = cvs_buf_release(rbuf);
@@ -618,7 +630,6 @@ rcs_getrev(RCSFILE *rfp, RCSNUM *rev)
}
}
-
return (rbuf);
}