diff options
author | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-03-05 16:22:32 +0000 |
---|---|---|
committer | Niall O'Higgins <niallo@cvs.openbsd.org> | 2006-03-05 16:22:32 +0000 |
commit | 5370036c987bf67a9edc99347ca3419134a235e3 (patch) | |
tree | e02f14c04f6d9dcea55428b5f18204fd3a7e6874 /usr.bin/cvs/rcs.c | |
parent | 94d21f75c148d389c7cadb791478c2fc0d274476 (diff) |
in rcs_patch_lines(), ensure that rcs patch delete operations don't
leave the dlp pointing at a non-existant line, but instead point it to
the last one in our TAILQ.
this fixes an annoying bug in rcs_patch_lines() where dlp would be
sometimes set to NULL when really it shouldn't be, resulting in an
"invalid line specification in RCS patch" error.
ok xsa@ joris@
Diffstat (limited to 'usr.bin/cvs/rcs.c')
-rw-r--r-- | usr.bin/cvs/rcs.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/cvs/rcs.c b/usr.bin/cvs/rcs.c index adc6c752105..0ee9049eadd 100644 --- a/usr.bin/cvs/rcs.c +++ b/usr.bin/cvs/rcs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcs.c,v 1.132 2006/03/05 16:06:59 niallo Exp $ */ +/* $OpenBSD: rcs.c,v 1.133 2006/03/05 16:22:31 niallo Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -1110,8 +1110,8 @@ rcs_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines) if (dlp->l_lineno > lineno) { dlp = TAILQ_PREV(dlp, cvs_tqh, l_list); } else if (dlp->l_lineno < lineno) { - ndlp = TAILQ_NEXT(dlp, l_list); - if (ndlp->l_lineno > lineno) + if (((ndlp = TAILQ_NEXT(dlp, l_list)) == NULL) || + (ndlp->l_lineno > lineno)) break; dlp = ndlp; } @@ -1124,6 +1124,12 @@ rcs_patch_lines(struct cvs_lines *dlines, struct cvs_lines *plines) ndlp = TAILQ_NEXT(dlp, l_list); TAILQ_REMOVE(&(dlines->l_lines), dlp, l_list); dlp = ndlp; + /* last line is gone - reset dlp */ + if (dlp == NULL) { + ndlp = TAILQ_LAST(&(dlines->l_lines), + cvs_tqh); + dlp = ndlp; + } } } else if (op == 'a') { for (i = 0; i < nbln; i++) { |