]> granicus.if.org Git - llvm/commitdiff
Fix r357749 for big-endian architectures
authorPavel Labath <pavel@labath.sk>
Fri, 5 Apr 2019 08:43:54 +0000 (08:43 +0000)
committerPavel Labath <pavel@labath.sk>
Fri, 5 Apr 2019 08:43:54 +0000 (08:43 +0000)
We need to read the strings from the minidump files as little-endian,
regardless of the host byte order.

I definitely remember thinking about this case while writing the patch
(and in fact, I have implemented that for the "write" case), but somehow
I have ended up not implementing the byte swapping when reading the
data. This adds the necessary byte-swapping and should hopefully fix
test failures on big-endian bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357754 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/Minidump.cpp

index 3e3255a2f17cb663a1ea83a63718a95b07dccc0c..1a22491ce3c30bce4054001fa15d0e756d3f81b6 100644 (file)
@@ -38,12 +38,16 @@ Expected<std::string> MinidumpFile::getString(size_t Offset) const {
     return "";
 
   Offset += sizeof(support::ulittle32_t);
-  auto ExpectedData = getDataSliceAs<UTF16>(getData(), Offset, Size);
+  auto ExpectedData =
+      getDataSliceAs<support::ulittle16_t>(getData(), Offset, Size);
   if (!ExpectedData)
     return ExpectedData.takeError();
 
+  SmallVector<UTF16, 32> WStr(Size);
+  copy(*ExpectedData, WStr.begin());
+
   std::string Result;
-  if (!convertUTF16ToUTF8String(*ExpectedData, Result))
+  if (!convertUTF16ToUTF8String(WStr, Result))
     return createError("String decoding failed");
 
   return Result;