mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(transformer): fix memory leak in ReplaceGlobalDefines (#6224)
`ReplaceGlobalDefines` was putting a `String` into the arena. `String` allocates on the heap, so this was a memory leak because it didn't get dropped when the allocator is dropped. This was caught by Miri. Allocate a string slice instead.
This commit is contained in:
parent
cc57541281
commit
4b42047fef
1 changed files with 1 additions and 1 deletions
|
|
@ -206,7 +206,7 @@ impl<'a> ReplaceGlobalDefines<'a> {
|
||||||
// Construct a new expression because we don't have ast clone right now.
|
// Construct a new expression because we don't have ast clone right now.
|
||||||
fn parse_value(&self, source_text: &str) -> Expression<'a> {
|
fn parse_value(&self, source_text: &str) -> Expression<'a> {
|
||||||
// Allocate the string lazily because replacement happens rarely.
|
// Allocate the string lazily because replacement happens rarely.
|
||||||
let source_text = self.allocator.alloc(source_text.to_string());
|
let source_text = self.allocator.alloc_str(source_text);
|
||||||
// Unwrapping here, it should already be checked by [ReplaceGlobalDefinesConfig::new].
|
// Unwrapping here, it should already be checked by [ReplaceGlobalDefinesConfig::new].
|
||||||
Parser::new(self.allocator, source_text, SourceType::default()).parse_expression().unwrap()
|
Parser::new(self.allocator, source_text, SourceType::default()).parse_expression().unwrap()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue