Skip to content

Commit 2951645

Browse files
committed
test(transformer/styled-components): fix memory leak (#12207)
Fix memory leak in tests for `styled-components` transform. ```rs let allocator = Box::leak(Box::new(Allocator::default())); let ast = AstBuilder::new(allocator); ``` Miri didn't run on the PR that introduced this code, but it caught the leak in an unrelated PR touching `oxc_allocator` which ran Miri in CI: https://github.com/oxc-project/oxc/actions/runs/16203915572/job/45749445785?pr=12203#step:5:822 I'm unclear why `Box::leak` was used here.
1 parent 7b1f4a5 commit 2951645

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/oxc_transformer/src/plugins/styled_components.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,8 +1256,8 @@ mod tests {
12561256

12571257
#[test]
12581258
fn returns_indices_of_removed_placeholders() {
1259-
let allocator = Box::leak(Box::new(Allocator::default()));
1260-
let ast = AstBuilder::new(allocator);
1259+
let allocator = Allocator::default();
1260+
let ast = AstBuilder::new(&allocator);
12611261

12621262
// Create raw values that will generate placeholders
12631263
let css = "this is some\ninput with __PLACEHOLDER_0__ and // ignored __PLACEHOLDER_1__";

0 commit comments

Comments
 (0)