[llvm-commits] CVS: llvm/lib/System/Unix/Path.cpp

Reid Spencer reid at x10sys.com
Thu Dec 2 01:09:59 PST 2004



Changes in directory llvm/lib/System/Unix:

Path.cpp updated: 1.14 -> 1.15
---
Log message:

Fix seriously broken implementation of GetMagicNumber.


---
Diffs of the changes:  (+6 -4)

Index: llvm/lib/System/Unix/Path.cpp
diff -u llvm/lib/System/Unix/Path.cpp:1.14 llvm/lib/System/Unix/Path.cpp:1.15
--- llvm/lib/System/Unix/Path.cpp:1.14	Tue Nov 16 11:14:08 2004
+++ llvm/lib/System/Unix/Path.cpp	Thu Dec  2 03:09:48 2004
@@ -178,11 +178,13 @@
   int fd = ::open(path.c_str(),O_RDONLY);
   if (fd < 0)
     return false;
-  if (0 != ::read(fd, buf, len))
+  ssize_t bytes_read = ::read(fd, buf, len);
+  ::close(fd);
+  if (ssize_t(len) != bytes_read) {
+    Magic.clear();
     return false;
-  close(fd);
-  buf[len] = '\0';
-  Magic = buf;
+  }
+  Magic.assign(buf,len);
   return true;
 }
 






More information about the llvm-commits mailing list