[llvm] r192769 - Fix a bug in Windows resource file detection.

Rui Ueyama ruiu at google.com
Tue Oct 15 20:29:49 PDT 2013


Author: ruiu
Date: Tue Oct 15 22:29:49 2013
New Revision: 192769

URL: http://llvm.org/viewvc/llvm-project?rev=192769&view=rev
Log:
Fix a bug in Windows resource file detection.

The magic bytes should not include the trailing NUL byte.

Modified:
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=192769&r1=192768&r2=192769&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Tue Oct 15 22:29:49 2013
@@ -849,7 +849,7 @@ error_code has_magic(const Twine &path,
   switch ((unsigned char)Magic[0]) {
     case 0x00: {
       // Windows resource file
-      const char Expected[] = "\0\0\0\0\x20\0\0\0\xff";
+      const char Expected[] = { 0, 0, 0, 0, '\x20', 0, 0, 0, '\xff' };
       if (Magic.size() >= sizeof(Expected) &&
           memcmp(Magic.data(), Expected, sizeof(Expected)) == 0)
         return file_magic::windows_resource;





More information about the llvm-commits mailing list