refactor(managed): read metadata pointer rows through BinaryReader (#12483)

Co-authored-by: 吴佳浩 <wujiahao@supremind.com>
This commit is contained in:
吴佳浩Albenand吴佳浩 authored and GitHub committed 2026-11-19 14:23:54 -05:00
1 parent 654c17b904
commit 3d0fa7dae2
2 files changed
+5 -3

No files matched your search

@@ -13,7 +13,6 @@
"src/domain/elfRelocation.ts": 6,
"src/domain/inesContainer.ts": 5,
"src/domain/managed/managedCliHeaderPrefix.ts": 5,
"src/domain/managed/managedMemberPointers.ts": 2,
"src/domain/managed/managedMetadataHeaps.ts": 4,
"src/domain/managed/managedMetadataInventoryRows.ts": 2,
"src/domain/managed/managedMetadataLayout.ts": 7,
+5 -2
View File
@@ -1,3 +1,4 @@
import { BinaryReader } from "../binaryContainer.js";
import { managedDecodeBudget } from "./managedDecodeBudget.js";
import type {
ManagedMetadataLayout,
@@ -73,10 +74,12 @@ export const memberListRowLookup = (
const positions = new Uint32Array(definitionCount + 1);
try {
const width = layout.tableIndexSize(table);
// The pointer table's index width is a property of the layout, not of the row, so one
// reader covers the whole scan and each row keeps the width the table declares.
const reader = new BinaryReader(bytes, true, "managed-metadata-pointers");
for (let row = 1; row <= pointers.rowCount; row += 1) {
const offset: number = pointers.offset + (row - 1) * pointers.rowSize;
const definition =
width === 2 ? bytes.readUInt16LE(offset) : bytes.readUInt32LE(offset);
const definition = width === 2 ? reader.u16(offset) : reader.u32(offset);
if (definition === 0 || definition > definitionCount)
throw managedFailure(
"invalid-row",