Skip to content

Commit 59f5263

Browse files
committed
fix: string lifetime
1 parent ce39d39 commit 59f5263

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

shared/helpers/Serialization.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ alt::MValue V8Helpers::V8ToMValue(v8::Local<v8::Value> val, bool allowFunction)
3535

3636
if(val->IsNumber()) return core.CreateMValueDouble(val->NumberValue(ctx).ToChecked());
3737

38-
if(val->IsString()) return core.CreateMValueString(*v8::String::Utf8Value(isolate, val));
38+
if(val->IsString())
39+
{
40+
auto jsStr = v8::String::Utf8Value(isolate, val);
41+
return core.CreateMValueString(*jsStr);
42+
}
3943

4044
if(val->IsObject())
4145
{
@@ -154,8 +158,8 @@ alt::MValue V8Helpers::V8ToMValue(v8::Local<v8::Value> val, bool allowFunction)
154158
V8_CHECK_RETN(v8Obj->Get(ctx, v8Key).ToLocal(&value), "Failed to convert object to MValue", core.CreateMValueNil());
155159

156160
if(value->IsUndefined()) continue;
157-
auto key = *v8::String::Utf8Value(isolate, v8Key);
158-
dict->Set(key, V8ToMValue(value, allowFunction));
161+
auto key = v8::String::Utf8Value(isolate, v8Key);
162+
dict->Set(*key, V8ToMValue(value, allowFunction));
159163
}
160164

161165
return dict;

0 commit comments

Comments
 (0)