From b02c33c0c28ac187ecd282a8fbc6ef5d90d6fee5 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Fri, 5 Apr 2019 08:43:54 +0000 Subject: [PATCH] Fix r357749 for big-endian architectures 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. llvm-svn: 357754 --- lib/Object/Minidump.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Object/Minidump.cpp b/lib/Object/Minidump.cpp index 3e3255a2f17..1a22491ce3c 100644 --- a/lib/Object/Minidump.cpp +++ b/lib/Object/Minidump.cpp @@ -38,12 +38,16 @@ Expected MinidumpFile::getString(size_t Offset) const { return ""; Offset += sizeof(support::ulittle32_t); - auto ExpectedData = getDataSliceAs(getData(), Offset, Size); + auto ExpectedData = + getDataSliceAs(getData(), Offset, Size); if (!ExpectedData) return ExpectedData.takeError(); + SmallVector WStr(Size); + copy(*ExpectedData, WStr.begin()); + std::string Result; - if (!convertUTF16ToUTF8String(*ExpectedData, Result)) + if (!convertUTF16ToUTF8String(WStr, Result)) return createError("String decoding failed"); return Result;