0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-21 15:04:33 -05:00

Fix ValueDeserializer::read_value() lifetime (#609)

The return value should have the lifetime of the context, not the
deserializer.

Fixes #607.
This commit is contained in:
Ben Noordhuis 2021-02-10 07:27:27 +01:00 committed by GitHub
parent 9a8f6443fe
commit 5dc6117dd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -261,7 +261,10 @@ pub trait ValueDeserializerHelper {
.into()
}
fn read_value(&mut self, context: Local<Context>) -> Option<Local<Value>> {
fn read_value<'s>(
&mut self,
context: Local<'s, Context>,
) -> Option<Local<'s, Value>> {
unsafe {
Local::from_raw(v8__ValueDeserializer__ReadValue(
self.get_cxx_value_deserializer(),
@ -413,10 +416,10 @@ impl<'a, 's> ValueDeserializer<'a, 's> {
}
}
pub fn read_value(
pub fn read_value<'t>(
&mut self,
context: Local<Context>,
) -> Option<Local<Value>> {
context: Local<'t, Context>,
) -> Option<Local<'t, Value>> {
(*self.value_deserializer_heap).read_value(context)
}
}

View file

@ -4240,6 +4240,7 @@ fn value_serializer_and_deserializer_js_objects() {
let name = v8::String::new(scope, "objects").unwrap();
let objects: v8::Local<v8::Value> =
value_deserializer.read_value(context).unwrap();
drop(value_deserializer);
context.global(scope).set(scope, name.into(), objects);
@ -4343,6 +4344,7 @@ fn value_serializer_and_deserializer_array_buffers() {
let name = v8::String::new(scope, "objects").unwrap();
let objects: v8::Local<v8::Value> =
value_deserializer.read_value(context).unwrap();
drop(value_deserializer);
context.global(scope).set(scope, name.into(), objects);