Stop panic propagation on malloc_stats_print() callback.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk committed 2025-12-01 05:20:26 +00:00
1 parent bcc2be7661
commit 74f8cd3708
1 file changed
+6
+6
View File
@@ -117,6 +117,12 @@ pub fn memory_stats(opts: &str) -> Option<String> {
}
unsafe extern "C" fn malloc_stats_cb(opaque: *mut c_void, msg: *const c_char) {
catch_unwind(move || handle_malloc_stats(opaque, msg))
.map_err(|_| abort())
.ok();
}
fn handle_malloc_stats(opaque: *mut c_void, msg: *const c_char) {
// SAFETY: we have to trust the opaque points to our String
let res: &mut String = unsafe {
opaque