diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2006-04-18 02:49:32 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2006-04-18 02:49:32 +0000 |
commit | d9b9816271e58dc23c1e8998310d856783c8cf0c (patch) | |
tree | b15f2b75142713a535bc1eaa320582d42262fdf6 /usr.bin/rcs/ci.c | |
parent | c5187000c71672b7aa0f0345b9545431b83b69d0 (diff) |
Removes memory leaks when flags are called multiple times. This
is the easy way out. The code should be able to handle having
pb.author, pb.description, and pb.symbol as const char * strings
pointing to rcs_optarg values without using xstrdup at all. The
code is a bit hairy so it's difficult to verify that it's done
correctly, so that'll be a plan for another day. In the meantime,
this works.
OK joris@
Diffstat (limited to 'usr.bin/rcs/ci.c')
-rw-r--r-- | usr.bin/rcs/ci.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c index 6932b30183d..bc8921d0663 100644 --- a/usr.bin/rcs/ci.c +++ b/usr.bin/rcs/ci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ci.c,v 1.150 2006/04/18 02:46:21 ray Exp $ */ +/* $OpenBSD: ci.c,v 1.151 2006/04/18 02:49:31 ray Exp $ */ /* * Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org> * All rights reserved. @@ -62,8 +62,7 @@ struct checkin_params { RCSFILE *file; RCSNUM *frev, *newrev; char fpath[MAXPATHLEN], *rcs_msg, *username, *deltatext, *filename; - char *author, *state; - const char *symbol, *description; + char *author, *description, *state, *symbol; }; static int checkin_attach_symbol(struct checkin_params *); @@ -161,12 +160,16 @@ checkin_main(int argc, char **argv) pb.flags &= ~INTERACTIVE; break; case 'N': + if (pb.symbol != NULL) + xfree(pb.symbol); pb.symbol = xstrdup(rcs_optarg); if (rcs_sym_check(pb.symbol) != 1) fatal("invalid symbol `%s'", pb.symbol); pb.flags |= CI_SYMFORCE; break; case 'n': + if (pb.symbol != NULL) + xfree(pb.symbol); pb.symbol = xstrdup(rcs_optarg); if (rcs_sym_check(pb.symbol) != 1) fatal("invalid symbol `%s'", pb.symbol); @@ -187,6 +190,8 @@ checkin_main(int argc, char **argv) pb.flags |= PRESERVETIME; break; case 't': + if (pb.description != NULL) + xfree(pb.description); pb.description = xstrdup(rcs_optarg); break; case 'u': @@ -198,6 +203,8 @@ checkin_main(int argc, char **argv) exit(0); /* NOTREACHED */ case 'w': + if (pb.author != NULL) + xfree(pb.author); pb.author = xstrdup(rcs_optarg); break; case 'x': |