[PATCH] D34159: Fix a bug introduced in r305092 on big-endian systems.

Eric Beckmann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 13:53:35 PDT 2017


ecbeckmann updated this revision to Diff 102402.
ecbeckmann added a comment.

Use writele16 instead of casting.


https://reviews.llvm.org/D34159

Files:
  llvm/lib/Object/WindowsResource.cpp


Index: llvm/lib/Object/WindowsResource.cpp
===================================================================
--- llvm/lib/Object/WindowsResource.cpp
+++ llvm/lib/Object/WindowsResource.cpp
@@ -692,10 +692,8 @@
   // Now write the directory string table for .rsrc$01
   uint32_t TotalStringTableSize = 0;
   for (auto String : StringTable) {
-    auto *LengthField =
-        reinterpret_cast<uint16_t *>(BufferStart + CurrentOffset);
     uint16_t Length = String.size();
-    *LengthField = Length;
+    support::endian::write16le(BufferStart + CurrentOffset, Length);
     CurrentOffset += sizeof(uint16_t);
     auto *Start = reinterpret_cast<UTF16 *>(BufferStart + CurrentOffset);
     std::copy(String.begin(), String.end(), Start);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34159.102402.patch
Type: text/x-patch
Size: 740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/809bad20/attachment.bin>


More information about the llvm-commits mailing list