summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2010-08-31 06:36:33 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2010-08-31 06:36:33 +0000
commit18f5005eb086f3914bc506862dca27910674000f (patch)
treec067aef6d328562d96a6c22f11a1c6db57ff0903 /llvm
parent1279e737f55bb56309b4b578d6b2fa235f98f41a (diff)
downloadbcm5719-llvm-18f5005eb086f3914bc506862dca27910674000f.tar.gz
bcm5719-llvm-18f5005eb086f3914bc506862dca27910674000f.zip
System: Fix getMagicNumber on windows.
getMagicNumber was treating the _binary_ data it read in as a null terminated string. This resulted in the std::string calculating the length, and causing an assert in other code that assumed that the length it passed was the same as the length of the string it would get back. llvm-svn: 112586
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/System/Win32/Path.inc5
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc
index 42e58a47085..4a6dbd3ddf2 100644
--- a/llvm/lib/System/Win32/Path.inc
+++ b/llvm/lib/System/Win32/Path.inc
@@ -722,7 +722,7 @@ Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
assert(len < 1024 && "Request for magic string too long");
- char* buf = (char*) alloca(1 + len);
+ char* buf = reinterpret_cast<char*>(alloca(len));
HANDLE h = CreateFile(path.c_str(),
GENERIC_READ,
@@ -741,8 +741,7 @@ bool Path::getMagicNumber(std::string& Magic, unsigned len) const {
if (!ret || nRead != len)
return false;
- buf[len] = '\0';
- Magic = buf;
+ Magic = std::string(buf, len);
return true;
}
OpenPOWER on IntegriCloud