From 975a5ec60a8541bcc02197d38cd2b5e4765c6b07 Mon Sep 17 00:00:00 2001 From: "Dominik G." Date: Wed, 28 Jan 2026 01:38:24 +0100 Subject: [PATCH] fix invalid negative values in sourcemap column indexes (#17167) * add check for negative idx to sourcemaps test * fix: format * Update packages/svelte/tests/sourcemaps/test.ts --------- Co-authored-by: Rich Harris --- packages/svelte/tests/sourcemaps/test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/svelte/tests/sourcemaps/test.ts b/packages/svelte/tests/sourcemaps/test.ts index c654258b34..0ac0e6f905 100644 --- a/packages/svelte/tests/sourcemaps/test.ts +++ b/packages/svelte/tests/sourcemaps/test.ts @@ -96,6 +96,20 @@ const { test, run } = suite(async (config, cwd) => { const decoded = decode(map.mappings); + /* + Decoded sourcemap mappings contain absolute line/column numbers. + Negative values are invalid and can cause errors in downstream processing + */ + for (let l = 0; l < decoded.length; l++) { + for (let m of decoded[l]) { + if (m.some((i) => i < 0)) { + throw new Error( + `Invalid mapping with negative value ${JSON.stringify(m)} at line ${l} of the decoded mappings of ${info} sourcemap\n${JSON.stringify(map)}` + ); + } + } + } + try { for (let entry of entries) { entry = typeof entry === 'string' ? { str: entry } : entry;