From 46e2f89364ce24a06953d08c78218fb5548a9fa3 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 8 Jan 2020 17:13:54 +0000 Subject: [PATCH] [MC] writeFragment - assert MCFragment::FT_Fill length is legal. Silence (clang/MSVC) static analyzer warnings that the fragment data may either write out of bounds of the local array or reference uninitialized data. --- llvm/lib/MC/MCAssembler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 4a8421299f65..b30137aafb8d 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -572,6 +572,7 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm, unsigned VSize = FF.getValueSize(); const unsigned MaxChunkSize = 16; char Data[MaxChunkSize]; + assert(0 < VSize && VSize <= MaxChunkSize && "Illegal fragment fill size"); // Duplicate V into Data as byte vector to reduce number of // writes done. As such, do endian conversion here. for (unsigned I = 0; I != VSize; ++I) {