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

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 06:24:29 PDT 2026


Author: Igor Wodiany
Date: 2026-09-28T14:24:22+01:00
New Revision: 20913cfb73ee109c0ad4e9cb298e2c1a0595fb0b

URL: https://github.com/llvm/llvm-project/commit/20913cfb73ee109c0ad4e9cb298e2c1a0595fb0b
DIFF: https://github.com/llvm/llvm-project/commit/20913cfb73ee109c0ad4e9cb298e2c1a0595fb0b.diff

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

The `Base` is calculated as a product of two 32-bits number but the
results is assigned to a 64-bit value. By casting one of the operands to
64-bit, the multiplication is done using the whole width of the `Base`
variable, preventing a potential overflow. This fixes an issue reported
by a CodeQL scan.

Added: 
    

Modified: 
    llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp b/llvm/lib/DebugInfo/PDB/Native/LinePrinter.cpp
index f7149ca0a8236..1fa36650418bb 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