> Am 13.06.2025 um 00:14 schrieb Paul Eggert <egg...@cs.ucla.edu>:
> 
> That's obviously wrong; 'base' should not be a null pointer. Can you track 
> down why it is a null pointer?

First unsatisfactory first answer is: because of this call and the code used in 
the functions called:

        context.c  379            print_1_line (nullptr, line);
        
        util.c     981  /* Print the text of a single line LINE,
        util.c     982     flagging it with the characters in LINE_FLAG (which 
say whether
        util.c     983     the line is inserted, deleted, changed, etc.).  
LINE_FLAG must not
        util.c     984     end in a blank, unless it is a single blank.  */
        util.c     985  
        util.c     986  void
        util.c     987  print_1_line (char const *line_flag, char const *const 
*line)
        util.c     988  {
        util.c     989    print_1_line_nl (line_flag, line, false);
        util.c     990  }
        util.c     991  
        util.c     992  /* Print the text of a single line LINE,
        util.c     993     flagging it with the characters in LINE_FLAG (which 
say whether
        util.c     994     the line is inserted, deleted, changed, etc.).  
LINE_FLAG must not
        util.c     995     end in a blank, unless it is a single blank.  If 
SKIP_NL is set, then
        util.c     996     the final '\n' is not printed.  */
        util.c     997  
        util.c     998  void
        util.c     999  print_1_line_nl (char const *line_flag, char const 
*const *line, bool skip_nl)
        util.c    1000  {
===>    util.c    1001    char const *base = line[0], *limit = line[1]; /* Help 
the compiler.  */
        util.c    1002    FILE *out = outfile; /* Help the compiler some more.  
*/
        util.c    1003    char const *flag_format = nullptr;
        util.c    1004  
        util.c    1005    /* If -T was specified, use a Tab between the 
line-flag and the text.
        util.c    1006       Otherwise use a Space (as Unix diff does).
        util.c    1007       Print neither space nor tab if line-flags are 
empty.
        util.c    1008       But omit trailing blanks if requested.  */
        util.c    1009  
        util.c    1010    if (line_flag && *line_flag)
        util.c    1011      {

So presumingly the question is, why was line #379 in context.c reached? I'll 
check this on my other Mac where diff is working.

Another question seems to be, why is the null pointer used when calling 
fwrite()? A check should avoid this, rather early, and report or set some 
failure status…

--
Greetings

 Pete

One-Shot Case Study, n.:
The scientific equivalent of the four-leaf clover, from which it is concluded 
all clovers possess four leaves and are sometimes green.




Reply via email to