llvm.org GIT mirror llvm / ddb4f9c
Fix the Endianness bug by adding the little endian UTF marker. Summary: Quick fix Reviewers: zturner, uweigand Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33014 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302573 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Beckmann 3 years ago
2 changed file(s) with 8 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
16011601 uint16_t Length;
16021602 RETURN_IF_ERROR(Reader.readInteger(Length));
16031603 ArrayRef RawDirString;
1604 // Strings are stored as 2-byte aligned unicode characters but readFixedString
1605 // assumes byte string, so we double length.
16061604 RETURN_IF_ERROR(Reader.readArray(RawDirString, Length));
16071605 return RawDirString;
16081606 }
15611561 raw_svector_ostream OS(IDStr);
15621562 if (i < Table.NumberOfNameEntries) {
15631563 ArrayRef RawEntryNameString = unwrapOrError(RSF.getEntryNameString(Entry));
1564 std::vector EndianCorrectedNameString;
1565 if (llvm::sys::IsBigEndianHost) {
1566 EndianCorrectedNameString.resize(RawEntryNameString.size() + 1);
1567 std::copy(RawEntryNameString.begin(), RawEntryNameString.end(),
1568 EndianCorrectedNameString.begin() + 1);
1569 EndianCorrectedNameString[0] = UNI_UTF16_BYTE_ORDER_MARK_SWAPPED;
1570 RawEntryNameString = makeArrayRef(EndianCorrectedNameString);
1571 }
15641572 std::string EntryNameString;
15651573 if (!llvm::convertUTF16ToUTF8String(RawEntryNameString, EntryNameString))
15661574 error(object_error::parse_failed);