From 881819ebfbbe3a9df435ef3c27688935c5a36d60 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 16 Jun 2017 02:17:35 +0000 Subject: [PATCH] Fix msan buildbot. This patch should fix sanitizer-x86_64-linux-fast bot. The problem was that the contents of this stream are aligned to 4 byte, and the paddings were created just by incrementing `Offset`, so paddings had undefined values. When the entire stream is written to an output, it triggered msan. llvm-svn: 305541 --- llvm/lib/Support/BinaryStreamWriter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Support/BinaryStreamWriter.cpp b/llvm/lib/Support/BinaryStreamWriter.cpp index b22eb1ed12d0..9c47a5cf1f74 100644 --- a/llvm/lib/Support/BinaryStreamWriter.cpp +++ b/llvm/lib/Support/BinaryStreamWriter.cpp @@ -83,6 +83,7 @@ Error BinaryStreamWriter::padToAlignment(uint32_t Align) { uint32_t NewOffset = alignTo(Offset, Align); if (NewOffset > getLength()) return make_error(stream_error_code::stream_too_short); - Offset = NewOffset; + while (Offset < NewOffset) + writeInteger('\0'); return Error::success(); }