Skip to content

Commit 437de9f

Browse files
committed
fix: serde deserialize_borrowed_str method, should not drop memory
1 parent 23231ee commit 437de9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bindings/convert.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,11 @@ pub(crate) fn deserialize_borrowed_str<'a>(
538538

539539
let cstr = unsafe { std::ffi::CStr::from_ptr(ptr) };
540540

541-
let s = cstr.to_str().map_err(ValueError::InvalidString)?;
541+
let s = cstr
542+
.to_str()
543+
.map_err(ValueError::InvalidString)?
544+
.to_string()
545+
.leak();
542546

543547
// Free the c string.
544548
unsafe { q::JS_FreeCString(context, ptr) };

0 commit comments

Comments
 (0)