home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume7 / patch2 / patch6 < prev    next >
Internet Message Format  |  1987-01-05  |  5KB

  1. From ihnp4!sdcrdcf!lwall Tue Jan  6 04:49:05 1987
  2. Received: by mirror.TMC.COM (4.12/UUCP-Project/rel-1.0/08-20-86)
  3.     id AA23628; Tue, 6 Jan 87 04:47:12 est
  4. Received: by ihnp4.ATT.COM id AA15964; 5 Jan 87 21:07:00 CST (Mon)
  5. Received: by sdc.uucp (4.12/sdcrdcf)
  6.     id AA20371; Mon, 5 Jan 87 17:10:37 pst
  7. Date: Mon, 5 Jan 87 17:10:37 pst
  8. From: ihnp4!sdcrdcf!lwall (Larry Wall)
  9. Message-Id: <8701060110.AA20371@sdc.uucp>
  10. Subject: patch 2.0 patch #6
  11. Organization: System Development Corporation, Santa Monica
  12. Apparently-To: hplabs!seismo!mirror!source-archives
  13. Status: R
  14.  
  15. System: patch version 2.0
  16. Patch #: 6
  17. Priority: HIGH
  18. Subject: New-style context diffs can cause double call to free().
  19. From: lwall@sdcrdcf (Larry Wall)
  20.  
  21. Description:
  22.     When either the pattern section or the replacement section of
  23.     a hunk is omitted, patch copies the corresponding line from
  24.     the other section.  It does this by copying the pointer, not
  25.     by copying the line, so when the hunk is later freed, some
  26.     lines are freed twice.  This gives heartburn to many varieties
  27.     of the malloc package.
  28.  
  29. Fix:    From rn, say "| patch -d DIR", where DIR is your patch source
  30.     directory.  Outside of rn, say "cd DIR; patch <thisarticle".
  31.     If you don't have the patch program, apply the following by hand,
  32.     or get patch.
  33.  
  34.     If patch indicates that patchlevel is the wrong version, you may need
  35.     to apply one or more previous patches, or the patch may already
  36.     have been applied.  See the patchlevel.h file to find out what has or
  37.     has not been applied.  In any event, don't continue with the patch.
  38.  
  39.     If you are missing previous patches they can be obtained from me:
  40.  
  41.     Larry Wall
  42.     {allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
  43.  
  44.     If you send a mail message of the following form it will greatly speed
  45.     processing:
  46.  
  47.     Subject: Command
  48.     @SH mailpatch PATH patch 2.0 LIST
  49.            ^ note the c
  50.  
  51.     where PATH is a return path FROM ME TO YOU in bang notation, and LIST
  52.     is the number of one or more patches you need, separated by spaces,
  53.     commas, and/or hyphens.  Saying 35- says everything from 35 to the end.
  54.  
  55. Index: patchlevel.h
  56. Prereq: 5
  57. 1c1
  58. < #define PATCHLEVEL 5
  59. ---
  60. > #define PATCHLEVEL 6
  61.  
  62. Index: pch.c
  63. Prereq: 2.0.1.3
  64. *** pch.c.old    Mon Jan  5 17:03:02 1987
  65. *** pch.c    Mon Jan  5 17:03:26 1987
  66. ***************
  67. *** 1,4
  68. ! /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  69.    *
  70.    * $Log:    pch.c,v $
  71.    * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  72.  
  73. --- 1,4 -----
  74. ! /* $Header: pch.c,v 2.0.1.4 87/01/05 16:59:53 lwall Exp $
  75.    *
  76.    * $Log:    pch.c,v $
  77.    * Revision 2.0.1.4  87/01/05  16:59:53  lwall
  78. ***************
  79. *** 1,6
  80.   /* $Header: pch.c,v 2.0.1.3 86/11/14 10:08:33 lwall Exp $
  81.    *
  82.    * $Log:    pch.c,v $
  83.    * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  84.    * Fixed problem where a long pattern wouldn't grow the hunk.
  85.    * Also restored p_input_line when backtracking so error messages are right.
  86.  
  87. --- 1,9 -----
  88.   /* $Header: pch.c,v 2.0.1.4 87/01/05 16:59:53 lwall Exp $
  89.    *
  90.    * $Log:    pch.c,v $
  91. +  * Revision 2.0.1.4  87/01/05  16:59:53  lwall
  92. +  * New-style context diffs caused double call to free().
  93. +  * 
  94.    * Revision 2.0.1.3  86/11/14  10:08:33  lwall
  95.    * Fixed problem where a long pattern wouldn't grow the hunk.
  96.    * Also restored p_input_line when backtracking so error messages are right.
  97. ***************
  98. *** 40,45
  99.   static int p_indent;            /* indent to patch */
  100.   static LINENUM p_base;            /* where to intuit this time */
  101.   static LINENUM p_start;            /* where intuit found a patch */
  102.   
  103.   /* Prepare to look for the next patch in the patch file. */
  104.   
  105.  
  106. --- 43,50 -----
  107.   static int p_indent;            /* indent to patch */
  108.   static LINENUM p_base;            /* where to intuit this time */
  109.   static LINENUM p_start;            /* where intuit found a patch */
  110. + static LINENUM p_efake = -1;        /* end of faked up lines--don't free */
  111. + static LINENUM p_bfake = -1;        /* beg of faked up lines */
  112.   
  113.   /* Prepare to look for the next patch in the patch file. */
  114.   
  115. ***************
  116. *** 386,393
  117.       Reg2 int context = 0;
  118.   
  119.       while (p_end >= 0) {
  120. !     free(p_line[p_end]);        /* Changed from postdecrement */
  121. !     p_end--;            /* by Keenan Ross for BSD2.9  */
  122.       }
  123.       assert(p_end == -1);
  124.   
  125.  
  126. --- 391,401 -----
  127.       Reg2 int context = 0;
  128.   
  129.       while (p_end >= 0) {
  130. !     if (p_end == p_efake)
  131. !         p_end = p_bfake;        /* don't free twice */
  132. !     else
  133. !         free(p_line[p_end]);
  134. !     p_end--;
  135.       }
  136.       assert(p_end == -1);
  137.       p_efake = -1;
  138. ***************
  139. *** 390,395
  140.       p_end--;            /* by Keenan Ross for BSD2.9  */
  141.       }
  142.       assert(p_end == -1);
  143.   
  144.       p_max = hunkmax;            /* gets reduced when --- found */
  145.       if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) {
  146.  
  147. --- 398,404 -----
  148.       p_end--;
  149.       }
  150.       assert(p_end == -1);
  151. +     p_efake = -1;
  152.   
  153.       p_max = hunkmax;            /* gets reduced when --- found */
  154.       if (diff_type == CONTEXT_DIFF || diff_type == NEW_CONTEXT_DIFF) {
  155. ***************
  156. *** 637,642
  157.       
  158.       /* if there were omitted context lines, fill them in now */
  159.       if (fillcnt) {
  160.           while (fillcnt-- > 0) {
  161.           while (p_char[fillsrc] != ' ')
  162.               fillsrc++;
  163.  
  164. --- 646,653 -----
  165.       
  166.       /* if there were omitted context lines, fill them in now */
  167.       if (fillcnt) {
  168. +         p_bfake = filldst;        /* remember where not to free() */
  169. +         p_efake = filldst + fillcnt - 1;
  170.           while (fillcnt-- > 0) {
  171.           while (p_char[fillsrc] != ' ')
  172.               fillsrc++;
  173.  
  174.