fix(managed): budget decoding before representation expansion

Validation: integrated changes passed formatting, typecheck, lint, resolved module-boundary verification and git diff --check. Tests and real-provider workflows were not run.
This commit is contained in:
morluto
2026-10-11 00:03:19 +08:00
parent 6d4cefc4f7
commit 0f0d6e4d43
18 changed files with 705 additions and 362 deletions
+10 -1
View File
@@ -1,3 +1,4 @@
import type { ManagedDecodeBudget } from "./ManagedDecodeBudget.js";
import type {
ManagedExceptionRegion,
ManagedInstructionAnchor,
@@ -434,6 +435,7 @@ export const parseExceptionRegions = (
bytes: Buffer,
offset: number,
methodEnd: number,
budget?: ManagedDecodeBudget,
): ExceptionRegionParseResult => {
const regions: ManagedExceptionRegion[] = [];
let sectionOffset = offset;
@@ -487,7 +489,14 @@ export const parseExceptionRegions = (
);
const count = (size - 4) / clauseSize;
regions.push(...readExceptionClauses(bytes, sectionOffset + 4, count, fat));
budget?.reserve(count * 256, sectionOffset);
for (const region of readExceptionClauses(
bytes,
sectionOffset + 4,
count,
fat,
))
regions.push(region);
hasMoreSections = (kind & 0x80) !== 0;
sectionOffset += size;