[llvm] [PDB] Prevent potential overflow when calculating `Base` in `formatMsfStreamData` (PR #224662)

Igor Wodiany via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 09:49:10 PDT 2026


https://github.com/IgWod updated https://github.com/llvm/llvm-project/pull/224662

>From e0e9b56ed4eb21d7364ea140e065a924a274e1bd Mon Sep 17 00:00:00 2001
From: Igor Wodiany <igor.wodiany at amd.com>
Date: Thu, 17 Sep 2026 13:42:56 +0100
Subject: [PATCH] [DebugInfo] Prevent potential multiplication overflow

This fixes an issues reported by a CodeQL scan.
---
 llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp b/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp
index f7149ca0a8236e..1fa36650418bbf 100644
--- a/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp
@@ -231,7 +231,8 @@ void LinePrinter::formatMsfStreamData(StringRef Label, PDBFile &File,
     assert(FoundRun.ByteLen >= RunOffset);
     uint64_t Len = FoundRun.ByteLen - RunOffset;
     Len = std::min(Len, Reader.bytesRemaining());
-    uint64_t Base = FoundRun.Block * File.getBlockSize() + RunOffset;
+    uint64_t Base =
+        static_cast<uint64_t>(FoundRun.Block) * File.getBlockSize() + RunOffset;
     ArrayRef<uint8_t> Data;
     consumeError(Reader.readBytes(Data, Len));
     OS << format_bytes_with_ascii(Data, Base, 32, 4,



More information about the llvm-commits mailing list