mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Only check the file's length once in pdb.Msf.init
This commit is contained in:
parent
2cbeb85a96
commit
24cca2a55e
1 changed files with 3 additions and 2 deletions
|
|
@ -868,7 +868,8 @@ const Msf = struct {
|
||||||
return error.InvalidDebugInfo;
|
return error.InvalidDebugInfo;
|
||||||
if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2)
|
if (superblock.FreeBlockMapBlock != 1 and superblock.FreeBlockMapBlock != 2)
|
||||||
return error.InvalidDebugInfo;
|
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;
|
return error.InvalidDebugInfo;
|
||||||
switch (superblock.BlockSize) {
|
switch (superblock.BlockSize) {
|
||||||
// llvm only supports 4096 but we can handle any of these values
|
// 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 block_id = try directory.reader().readIntLittle(u32);
|
||||||
const n = (block_id % superblock.BlockSize);
|
const n = (block_id % superblock.BlockSize);
|
||||||
// 0 is for SuperBlock, 1 and 2 for FPMs.
|
// 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;
|
return error.InvalidBlockIndex;
|
||||||
blocks[j] = block_id;
|
blocks[j] = block_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue