[llvm] r305149 - Fix a ubsan failure introduced by r305092

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 11:07:24 PDT 2017


Author: vedantk
Date: Sat Jun 10 13:07:24 2017
New Revision: 305149

URL: http://llvm.org/viewvc/llvm-project?rev=305149&view=rev
Log:
Fix a ubsan failure introduced by r305092

lib/Object/WindowsResource.cpp:578:3: runtime error: store to
misaligned address 0x7fa09aedebbe for type 'unsigned int', which
requires 4 byte alignment
0x7fa09aedebbe: note: pointer points here
00 00 03 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00  00 00
            ^

Modified:
    llvm/trunk/lib/Object/WindowsResource.cpp

Modified: llvm/trunk/lib/Object/WindowsResource.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/WindowsResource.cpp?rev=305149&r1=305148&r2=305149&view=diff
==============================================================================
--- llvm/trunk/lib/Object/WindowsResource.cpp (original)
+++ llvm/trunk/lib/Object/WindowsResource.cpp Sat Jun 10 13:07:24 2017
@@ -574,8 +574,8 @@ void WindowsResourceCOFFWriter::writeSym
 
 void WindowsResourceCOFFWriter::writeStringTable() {
   // Just 4 null bytes for the string table.
-  auto COFFStringTable = reinterpret_cast<uint32_t *>(Current);
-  *COFFStringTable = 0;
+  auto COFFStringTable = reinterpret_cast<void *>(Current);
+  memset(COFFStringTable, 0, 4);
 }
 
 void WindowsResourceCOFFWriter::writeDirectoryTree() {




More information about the llvm-commits mailing list