Author: bapt
Date: Sat Apr 30 14:48:30 2016
New Revision: 298851
URL: https://svnweb.freebsd.org/changeset/base/298851

Log:
  When checking for binary file, check if ch is not EOF only ch actually got
  a value assigned
  
  Reported by:  pfg

Modified:
  head/usr.bin/sdiff/sdiff.c

Modified: head/usr.bin/sdiff/sdiff.c
==============================================================================
--- head/usr.bin/sdiff/sdiff.c  Sat Apr 30 14:47:45 2016        (r298850)
+++ head/usr.bin/sdiff/sdiff.c  Sat Apr 30 14:48:30 2016        (r298851)
@@ -514,12 +514,14 @@ istextfile(FILE *f)
        if (f == NULL)
                return (1);
        rewind(f);
-       for (i = 0; i <= MAX_CHECK || ch != EOF; i++) {
+       for (i = 0; i <= MAX_CHECK; i++) {
                ch = fgetc(f);
                if (ch == '\0') {
                        rewind(f);
                        return (0);
                }
+               if (ch == EOF)
+                       break;
        }
        rewind(f);
        return (1);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to