[gnu.utils.bug] Diff 1.4 bug with directory comparisons

root@didsgn.UUCP (didsgn) (01/24/89)

I have found a strange effect (a core dump :-) when the -N option is used
on diff 1.4 and you are trying to compare two directories. If in one of
the directories a binary file is found, but there is no such file in the
other directory, diff dumps. The problem is in analyze.c where it does
the comparison of the binary files. After the comparison, diff_2_files()
does a free() on the buffers that were allocated to read in the file's data.
However, since one file did not exist, the buffer didn't exist either
and a free(0) was attempted which caused the problem.

-Allan G. Schrum

 Digital Design, Inc.
 3060 Business Park Drive, Ste E
 Norcross, GA 30071

 (404) 447-0274

 ...!gatech!rebel!didsgn!allan

Below is a diff of analyze.c with the correction:

*** analyze.c	Mon Jan 23 14:59:57 1989
--- old_analyze.c	Mon Jan 23 14:59:12 1989
*************** diff_2_files (filevec, depth
*** 671,678 ****
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
! 	if ( filevec[i].buffer )
! 	  free (filevec[i].buffer);
        return differs;
      }
  
--- 671,677 ----
  		 filevec[0].name, filevec[1].name);
  
        for (i = 0; i < 2; ++i)
! 	free (filevec[i].buffer);
        return differs;
      }