[BACK]Return to buf.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/buf.c between version 1.25 and 1.26

version 1.25, 2012/11/07 14:18:41 version 1.26, 2015/04/25 15:33:47
Line 67 
Line 67 
  */   */
   
 #include <ctype.h>  #include <ctype.h>
   #include <limits.h>
 #include <stddef.h>  #include <stddef.h>
   #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdarg.h>  #include <stdarg.h>
Line 86 
Line 88 
 #define DO_STAT_BUF(a, b)  #define DO_STAT_BUF(a, b)
 #endif  #endif
   
   static void
   fatal_overflow()
   {
           fprintf(stderr, "buffer size overflow\n");
           exit(2);
   }
   
 /* BufExpand(bp, nb)  /* BufExpand(bp, nb)
  *      Expand buffer bp to hold upto nb additional   *      Expand buffer bp to hold upto nb additional
  *      chars.  Makes sure there's room for an extra '\0' char at   *      chars.  Makes sure there's room for an extra '\0' char at
Line 97 
Line 106 
         DO_STAT_BUF(bp, nb);                            \          DO_STAT_BUF(bp, nb);                            \
                                                         \                                                          \
         do {                                            \          do {                                            \
                 size *= 2 ;                             \                  if (size <= SIZE_MAX/2) {               \
                           size *= 2 ;                     \
                   } else {                                \
                           fatal_overflow();               \
                   }                                       \
         } while (size - occupied < (nb)+1+BUF_MARGIN);  \          } while (size - occupied < (nb)+1+BUF_MARGIN);  \
         (bp)->buffer = (bp)->inPtr = (bp)->endPtr =     \          (bp)->buffer = (bp)->inPtr = (bp)->endPtr =     \
                 erealloc((bp)->buffer, size);           \                  erealloc((bp)->buffer, size);           \

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26