Skip to content

Commit

Permalink
fix bitmask overflow when using slotted components (sveltejs#4077)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Dec 10, 2019
1 parent 691211a commit 566f145
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/compiler/compile/render_dom/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions test/runtime/samples/bitmask-overflow-3/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
solo: true,
error: `A is not defined`,
};
4 changes: 4 additions & 0 deletions test/runtime/samples/bitmask-overflow-3/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<script>
let x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31;
</script>
<A>foo</A>

0 comments on commit 566f145

Please sign in to comment.