diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-29 11:59:00 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-29 11:59:00 +0000 |
commit | 71f91eb3ec5f8077e005940b677da4337fe31c3d (patch) | |
tree | 2d8253cd6093dd5eeff2b132f85dbd0a7947b8b8 /usr.bin | |
parent | 0cb19a3dfe9a96dfc858abf939847d1084b74b95 (diff) |
Properly free dynamically allocated memory. Also skip needless checks.
> Diff from Igor Zinovik
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/cvs/commit.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index e40df06cd75..cd1bf4c223d 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.122 2008/01/28 21:32:00 tobias Exp $ */ +/* $OpenBSD: commit.c,v 1.123 2008/01/29 11:58:59 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -147,9 +147,7 @@ cvs_commit(int argc, char **argv) if (!(flags & CR_RECURSE_DIRS)) cvs_client_send_request("Argument -l"); - if (logmsg != NULL) - cvs_client_send_logmsg(logmsg); - + cvs_client_send_logmsg(logmsg); cvs_client_send_files(argv, argc); cvs_client_senddir("."); cvs_client_send_request("ci"); @@ -160,6 +158,7 @@ cvs_commit(int argc, char **argv) cvs_file_freelist(&files_affected); } + xfree(logmsg); return (0); } @@ -170,6 +169,8 @@ cvs_commit_check_files(struct cvs_file *cf) RCSNUM *branch, *brev; char rev[CVS_REV_BUFSZ]; + branch = brev = NULL; + cvs_log(LP_TRACE, "cvs_commit_check_files(%s)", cf->file_path); if (current_cvsroot->cr_method != CVS_METHOD_LOCAL) @@ -231,6 +232,7 @@ cvs_commit_check_files(struct cvs_file *cf) cvs_log(LP_ERR, "%s is not a branch revision", rev); conflicts_found++; + rcsnum_free(brev); return; } @@ -238,6 +240,8 @@ cvs_commit_check_files(struct cvs_file *cf) cvs_log(LP_ERR, "%s is not a branch revision", rev); conflicts_found++; + rcsnum_free(branch); + rcsnum_free(brev); return; } @@ -246,12 +250,19 @@ cvs_commit_check_files(struct cvs_file *cf) cvs_log(LP_ERR, "%s (%s) is not a branch", cf->file_ent->ce_tag, rev); conflicts_found++; + rcsnum_free(branch); + rcsnum_free(brev); return; } } } next: + if (branch != NULL) + rcsnum_free(branch); + if (brev != NULL) + rcsnum_free(brev); + if (cf->file_status == FILE_ADDED || cf->file_status == FILE_REMOVED || cf->file_status == FILE_MODIFIED) @@ -340,6 +351,7 @@ cvs_commit_local(struct cvs_file *cf) nrev = rcsnum_brtorev(brev); if (nrev == NULL) fatal("failed to create branch rev"); + rcsnum_free(brev); } else { fatal("this isnt suppose to happen, honestly"); } @@ -356,6 +368,8 @@ cvs_commit_local(struct cvs_file *cf) strlcpy(rbuf, "Non-existent", sizeof(rbuf)); } + if (rrev != NULL) + rcsnum_free(rrev); isnew = 0; if (cf->file_status == FILE_ADDED) { isnew = 1; |