Possible bug in patch 2.0 #6
usenet at soma.UUCP
usenet at soma.UUCP
Tue Jan 20 06:07:40 AEST 1987
I found that there was a possible bug in the diff for pch.c in the
latest patch patch. Here is the corrected diff.
Index: pch.c
*** pch.c.orig Fri Nov 28 16:55:11 1986
--- pch.c Mon Jan 19 14:06:27 1987
***************
*** 1,4
! /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
*
* $Log: pch.c,v $
* Revision 2.0.1.3 86/11/14 10:08:33 lwall
--- 1,4 -----
! /* $Header: pch.c,v 2.0.1.4 87/01/05 16:59:53 lwall Exp $
*
* $Log: pch.c,v $
* Revision 2.0.1.4 87/01/05 16:59:53 lwall
***************
*** 1,6
/* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
*
* $Log: pch.c,v $
* Revision 2.0.1.3 86/11/14 10:08:33 lwall
* Fixed problem where a long pattern wouldn't grow the hunk.
* Also restored p_input_line when backtracking so error messages are right.
--- 1,9 -----
/* $Header: pch.c,v 2.0.1.4 87/01/05 16:59:53 lwall Exp $
*
* $Log: pch.c,v $
+ * Revision 2.0.1.4 87/01/05 16:59:53 lwall
+ * New-style context diffs caused double call to free().
+ *
* Revision 2.0.1.3 86/11/14 10:08:33 lwall
* Fixed problem where a long pattern wouldn't grow the hunk.
* Also restored p_input_line when backtracking so error messages are right.
***************
*** 40,45
static int p_indent; /* indent to patch */
static LINENUM p_base; /* where to intuit this time */
static LINENUM p_start; /* where intuit found a patch */
/* Prepare to look for the next patch in the patch file. */
--- 43,50 -----
static int p_indent; /* indent to patch */
static LINENUM p_base; /* where to intuit this time */
static LINENUM p_start; /* where intuit found a patch */
+ static LINENUM p_efake = -1; /* end of faked up lines--don't free */
+ static LINENUM p_bfake = -1; /* beg of faked up lines */
/* Prepare to look for the next patch in the patch file. */
***************
*** 386,393
Reg2 int context = 0;
while (p_end >= 0) {
! free(p_line[p_end]); /* Changed from postdecrement */
! p_end--; /* by Keenan Ross for BSD2.9 */
}
assert(p_end == -1);
--- 391,402 -----
Reg2 int context = 0;
while (p_end >= 0) {
! if (p_end == p_efake)
! p_end = p_bfake; /* don't free twice */
! else
! free(p_line[p_end]);
! p_end--;
!
}
assert(p_end == -1);
p_efake = -1;
***************
*** 390,395
p_end--; /* by Keenan Ross for BSD2.9 */
}
assert(p_end == -1);
p_max = hunkmax; /* gets reduced when --- found */
if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) {
--- 399,405 -----
}
assert(p_end == -1);
+ p_efake = -1;
p_max = hunkmax; /* gets reduced when --- found */
if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) {
***************
*** 637,642
/* if there were omitted context lines, fill them in now */
if (fillcnt) {
while (fillcnt-- > 0) {
while (p_char[fillsrc] != ' ')
fillsrc++;
--- 647,654 -----
/* if there were omitted context lines, fill them in now */
if (fillcnt) {
+ p_bfake = filldst; /* remember where not to free() */
+ p_efake = filldst + fillcnt - 1;
while (fillcnt-- > 0) {
while (p_char[fillsrc] != ' ')
fillsrc++;
Stan uucp:{shell,rice,cuae2}!soma!sob Opinions expressed here
Olan domain:sob at rice.edu or sob at soma.bcm.tmc.edu are ONLY mine &
Barber CIS:71565,623 BBS:(713)790-9004 noone else's.
More information about the Comp.sources.bugs
mailing list