diff options
author | Joris Vink <joris@cvs.openbsd.org> | 2008-02-26 20:20:50 +0000 |
---|---|---|
committer | Joris Vink <joris@cvs.openbsd.org> | 2008-02-26 20:20:50 +0000 |
commit | 6add2af7942b9d6321c3d80fa1d4c51b7f220f21 (patch) | |
tree | d03f2efed26d704f22d9a40a6bd77e90ceab5536 /usr.bin/cvs | |
parent | 428d5bffb0753c255bd3a6e7451b227979e281ec (diff) |
plug memleaks
based upon a diff from Igor Zinovik
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r-- | usr.bin/cvs/modules.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c index ff076b0bb89..500f1be6e68 100644 --- a/usr.bin/cvs/modules.c +++ b/usr.bin/cvs/modules.c @@ -1,4 +1,4 @@ -/* $OpenBSD: modules.c,v 1.10 2008/02/06 22:43:22 joris Exp $ */ +/* $OpenBSD: modules.c,v 1.11 2008/02/26 20:20:49 joris Exp $ */ /* * Copyright (c) 2008 Joris Vink <joris@openbsd.org> * @@ -57,6 +57,7 @@ modules_parse_line(char *line, int lineno) char *bline, *val, *p, *module, *sp, *dp; char *dirname, fpath[MAXPATHLEN], *prog; + prog = NULL; bline = xstrdup(line); flags = 0; @@ -80,7 +81,6 @@ modules_parse_line(char *line, int lineno) while (!isspace(*p) && *p != '\0') p++; - prog = NULL; while (val[0] == '-') { p = val; while (!isspace(*p) && *p != '\0') @@ -95,14 +95,14 @@ modules_parse_line(char *line, int lineno) case 'a': if (flags & MODULE_TARGETDIR) { cvs_log(LP_NOTICE, "cannot use -a with -d"); - return; + goto bad; } flags |= MODULE_ALIAS; break; case 'd': if (flags & MODULE_ALIAS) { cvs_log(LP_NOTICE, "cannot use -d with -a"); - return; + goto bad; } flags |= MODULE_TARGETDIR; break; @@ -113,7 +113,7 @@ modules_parse_line(char *line, int lineno) if (flags != 0 || prog != NULL) { cvs_log(LP_NOTICE, "-o cannot be used with other flags"); - return; + goto bad; } val = p; @@ -131,7 +131,7 @@ modules_parse_line(char *line, int lineno) if (flags != 0 || prog != NULL) { cvs_log(LP_NOTICE, "-i cannot be used with other flags"); - return; + goto bad; } if ((val = strchr(p, ' ' )) == NULL) @@ -202,6 +202,9 @@ modules_parse_line(char *line, int lineno) return; bad: + if (prog != NULL) + xfree(prog); + xfree(bline); cvs_log(LP_NOTICE, "malformed line in CVSROOT/modules: %d", lineno); } @@ -215,7 +218,6 @@ cvs_module_lookup(char *name) TAILQ_FOREACH(mi, &modules, m_list) { if (!strcmp(name, mi->mi_name)) { - mc = xmalloc(sizeof(*mc)); mc->mc_modules = mi->mi_modules; mc->mc_ignores = mi->mi_ignores; mc->mc_canfree = 0; |