From 566f1458f8ee135c5ba30a3b3080c256700764ec Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 10 Dec 2019 09:24:05 -0500 Subject: [PATCH] fix bitmask overflow when using slotted components (#4077) --- src/compiler/compile/render_dom/Renderer.ts | 6 +++++- test/runtime/samples/bitmask-overflow-3/_config.js | 4 ++++ test/runtime/samples/bitmask-overflow-3/main.svelte | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/bitmask-overflow-3/_config.js create mode 100644 test/runtime/samples/bitmask-overflow-3/main.svelte diff --git a/src/compiler/compile/render_dom/Renderer.ts b/src/compiler/compile/render_dom/Renderer.ts index 29389ed3c3d8..035b47e74f7c 100644 --- a/src/compiler/compile/render_dom/Renderer.ts +++ b/src/compiler/compile/render_dom/Renderer.ts @@ -220,7 +220,11 @@ export default class Renderer { const i = (value / 31) | 0; const n = 1 << (value % 31); - if (!bitmask[i]) bitmask[i] = { n: 0, names: [] }; + if (bitmask.length <= i) { + for (let j = bitmask.length; j <= i; j++) { + bitmask[j] = { n: 0, names: [] }; + } + } bitmask[i].n |= n; bitmask[i].names.push(name); diff --git a/test/runtime/samples/bitmask-overflow-3/_config.js b/test/runtime/samples/bitmask-overflow-3/_config.js new file mode 100644 index 000000000000..13f18b386cb2 --- /dev/null +++ b/test/runtime/samples/bitmask-overflow-3/_config.js @@ -0,0 +1,4 @@ +export default { + solo: true, + error: `A is not defined`, +}; \ No newline at end of file diff --git a/test/runtime/samples/bitmask-overflow-3/main.svelte b/test/runtime/samples/bitmask-overflow-3/main.svelte new file mode 100644 index 000000000000..aa2c56a14759 --- /dev/null +++ b/test/runtime/samples/bitmask-overflow-3/main.svelte @@ -0,0 +1,4 @@ + +foo