authorgravatar for gereeter+code@gmail.comJonathan S <gereeter+code@gmail.com> 2021-12-21 13:11:14-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-12-21 17:29:23-08:00
log24cca2a55e9fce5bd13bbda731cfa632885bcd3f
tree61490e5422d65250e378d8590cad04a584f3ba80
parent2cbeb85a96af25f2718a604aa2bec4f76dd85018

Only check the file's length once in pdb.Msf.init


1 files changed, 3 insertions(+), 2 deletions(-)

lib/std/pdb.zig+3-2
......@@ -868,7 +868,8 @@ const Msf = struct {
868868 return error.InvalidDebugInfo;
869869 if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2)
870870 return error.InvalidDebugInfo;
871 if (superblock.NumBlocks * superblock.BlockSize != try file.getEndPos())
871 const file_len = try file.getEndPos();
872 if (superblock.NumBlocks * superblock.BlockSize != file_len)
872873 return error.InvalidDebugInfo;
873874 switch (superblock.BlockSize) {
874875 // llvm only supports 4096 but we can handle any of these values
......@@ -919,7 +920,7 @@ const Msf = struct {
919920 const block_id = try directory.reader().readIntLittle(u32);
920921 const n = (block_id % superblock.BlockSize);
921922 // 0 is for SuperBlock, 1 and 2 for FPMs.
922 if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > try file.getEndPos())
923 if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > file_len)
923924 return error.InvalidBlockIndex;
924925 blocks[j] = block_id;
925926 }