Skip to content

Commit 7bda30f

Browse files
committed
feat(zts): fix memory leak test in zts
1 parent 27a8f3d commit 7bda30f

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/zend/try_catch.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,22 @@ mod tests {
179179

180180
#[test]
181181
fn test_memory_leak() {
182-
let mut ptr = null_mut();
182+
Embed::run(|| {
183+
let mut ptr = null_mut();
183184

184-
let _ = try_catch(|| {
185-
let mut result = "foo".to_string();
186-
ptr = &mut result;
185+
let _ = try_catch(|| {
186+
let mut result = "foo".to_string();
187+
ptr = &mut result;
187188

188-
unsafe {
189-
bailout();
190-
}
191-
});
189+
unsafe {
190+
bailout();
191+
}
192+
});
192193

193-
// Check that the string is never released
194-
let result = unsafe { &*ptr as &str };
194+
// Check that the string is never released
195+
let result = unsafe { &*ptr as &str };
195196

196-
assert_eq!(result, "foo");
197+
assert_eq!(result, "foo");
198+
});
197199
}
198200
}

0 commit comments

Comments
 (0)