]> granicus.if.org Git - llvm/commitdiff
Fix a ubsan failure introduced by r305092
authorVedant Kumar <vsk@apple.com>
Sat, 10 Jun 2017 18:07:24 +0000 (18:07 +0000)
committerVedant Kumar <vsk@apple.com>
Sat, 10 Jun 2017 18:07:24 +0000 (18:07 +0000)
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
            ^

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305149 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/WindowsResource.cpp

index 041659e7aa239364caaf56e95a6a316192e2681d..3a1ed9a907a24b65cb8210807719c349a65168cb 100644 (file)
@@ -574,8 +574,8 @@ void WindowsResourceCOFFWriter::writeSymbolTable() {
 
 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() {