[llvm-commits] [llvm] r116925 - /llvm/trunk/lib/System/Win32/Path.inc
Michael J. Spencer
bigcheesegs at gmail.com
Wed Oct 20 08:23:58 PDT 2010
Author: mspencer
Date: Wed Oct 20 10:23:58 2010
New Revision: 116925
URL: http://llvm.org/viewvc/llvm-project?rev=116925&view=rev
Log:
System-Win32/Path: Fix incorrect assumption in isValid.
A recent commit to clang exposed a bug in the Win32 Path code. This is a
minimal fix for it.
Modified:
llvm/trunk/lib/System/Win32/Path.inc
Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=116925&r1=116924&r2=116925&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Wed Oct 20 10:23:58 2010
@@ -64,6 +64,13 @@
return *this;
}
+// push_back 0 on create, and pop_back on delete.
+struct ScopedNullTerminator {
+ std::string &str;
+ ScopedNullTerminator(std::string &s) : str(s) { str.push_back(0); }
+ ~ScopedNullTerminator() { str.pop_back(); }
+};
+
bool
Path::isValid() const {
if (path.empty())
@@ -72,6 +79,8 @@
// If there is a colon, it must be the second character, preceded by a letter
// and followed by something.
size_t len = path.size();
+ // This code assumes that path is null terminated, so make sure it is.
+ ScopedNullTerminator snt(path);
size_t pos = path.rfind(':',len);
size_t rootslash = 0;
if (pos != std::string::npos) {
More information about the llvm-commits
mailing list