[test-suite] r255606 - fpcmp: Fix crash when comparing an empty file with tolerance

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 14 18:51:08 PST 2015


Author: matze
Date: Mon Dec 14 20:51:07 2015
New Revision: 255606

URL: http://llvm.org/viewvc/llvm-project?rev=255606&view=rev
Log:
fpcmp: Fix crash when comparing an empty file with tolerance

Modified:
    test-suite/trunk/tools/fpcmp.c

Modified: test-suite/trunk/tools/fpcmp.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/tools/fpcmp.c?rev=255606&r1=255605&r2=255606&view=diff
==============================================================================
--- test-suite/trunk/tools/fpcmp.c (original)
+++ test-suite/trunk/tools/fpcmp.c Mon Dec 14 20:51:07 2015
@@ -264,6 +264,12 @@ int diff_files_with_tolerance(const char
       return 1;
   }
 
+  // Avoid reading before byte 0 in the loop below.
+  if (A_size == 0 || B_size == 0) {
+    fprintf(stderr, "%s File sizes differ\n", g_program);
+    return 1;
+  }
+
   // Okay, we reached the end of file.  If both files are at the end, we
   // succeeded.
   bool F1AtEnd = F1P >= File1End;




More information about the llvm-commits mailing list