aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan S <gereeter+code@gmail.com>2021-12-21 13:11:14 -0600
committerAndrew Kelley <andrew@ziglang.org>2021-12-21 17:29:23 -0800
commit24cca2a55e9fce5bd13bbda731cfa632885bcd3f (patch)
tree61490e5422d65250e378d8590cad04a584f3ba80
parent2cbeb85a96af25f2718a604aa2bec4f76dd85018 (diff)
downloadzig-24cca2a55e9fce5bd13bbda731cfa632885bcd3f.tar.gz
zig-24cca2a55e9fce5bd13bbda731cfa632885bcd3f.zip
Only check the file's length once in pdb.Msf.init
-rw-r--r--lib/std/pdb.zig5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/std/pdb.zig b/lib/std/pdb.zig
index 0a484fed31..03f78cb179 100644
--- a/lib/std/pdb.zig
+++ b/lib/std/pdb.zig
@@ -868,7 +868,8 @@ const Msf = struct {
return error.InvalidDebugInfo;
if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2)
return error.InvalidDebugInfo;
- if (superblock.NumBlocks * superblock.BlockSize != try file.getEndPos())
+ const file_len = try file.getEndPos();
+ if (superblock.NumBlocks * superblock.BlockSize != file_len)
return error.InvalidDebugInfo;
switch (superblock.BlockSize) {
// llvm only supports 4096 but we can handle any of these values
@@ -919,7 +920,7 @@ const Msf = struct {
const block_id = try directory.reader().readIntLittle(u32);
const n = (block_id % superblock.BlockSize);
// 0 is for SuperBlock, 1 and 2 for FPMs.
- if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > try file.getEndPos())
+ if (block_id == 0 or n == 1 or n == 2 or block_id * superblock.BlockSize > file_len)
return error.InvalidBlockIndex;
blocks[j] = block_id;
}