From: Pavel Labath Date: Fri, 5 Apr 2019 08:43:54 +0000 (+0000) Subject: Fix r357749 for big-endian architectures X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b27c5f5dd927fafc8a192ed40ef5d86624bc3336;p=llvm 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357754 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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;