diff --git a/symbolic-cabi/Cargo.toml b/symbolic-cabi/Cargo.toml index d4104d90d..2428aaeef 100644 --- a/symbolic-cabi/Cargo.toml +++ b/symbolic-cabi/Cargo.toml @@ -23,3 +23,4 @@ crate-type = ["cdylib"] proguard = { version = "5.0.0", features = ["uuid"] } sourcemap = "6.0.2" symbolic = { version = "10.1.2", path = "../symbolic", features = ["cfi", "debuginfo", "demangle", "sourcemapcache", "symcache"] } +tempfile = "3.1.0" diff --git a/symbolic-cabi/src/sourcemapcache.rs b/symbolic-cabi/src/sourcemapcache.rs index b3d25ac43..680372156 100644 --- a/symbolic-cabi/src/sourcemapcache.rs +++ b/symbolic-cabi/src/sourcemapcache.rs @@ -1,3 +1,4 @@ +use std::io::BufWriter; use std::ops::Deref; use std::os::raw::c_char; use std::ptr; @@ -93,10 +94,13 @@ ffi_fn! { String::from_utf8_lossy(source_slice).deref(), String::from_utf8_lossy(sourcemap_slice).deref() )?; - let mut buffer = Vec::new(); - writer.serialize(&mut buffer)?; - let byteview = ByteView::from_vec(buffer); + let file = tempfile::tempfile()?; + let mut buf_writer = BufWriter::new(file); + writer.serialize(&mut buf_writer)?; + let file = buf_writer.into_inner()?; + + let byteview = ByteView::map_file(file)?; let inner = SelfCell::try_new::(byteview, |data| { let cache = SourceMapCache::parse(&*data)?; Ok(Inner { cache })