From 5370036c987bf67a9edc99347ca3419134a235e3 Mon Sep 17 00:00:00 2001 From: Niall O'Higgins Date: Sun, 5 Mar 2006 16:22:32 +0000 Subject: 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@ --- usr.bin/cvs/rcs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'usr.bin/cvs/rcs.c') 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 * 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++) { -- cgit v1.2.3