Skip to content

Commit 5e14fd1

Browse files
joyeecheungRafaelGSS
authored andcommitted
src: enter and lock isolate properly in json parser
PR-URL: #57823 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com>
1 parent 0df87e0 commit 5e14fd1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/json_parser.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ bool JSONParser::Parse(const std::string& content) {
1818
DCHECK(!parsed_);
1919

2020
Isolate* isolate = isolate_.get();
21+
v8::Locker locker(isolate);
2122
v8::Isolate::Scope isolate_scope(isolate);
2223
v8::HandleScope handle_scope(isolate);
2324

@@ -47,6 +48,7 @@ bool JSONParser::Parse(const std::string& content) {
4748
std::optional<std::string> JSONParser::GetTopLevelStringField(
4849
std::string_view field) {
4950
Isolate* isolate = isolate_.get();
51+
v8::Locker locker(isolate);
5052
v8::Isolate::Scope isolate_scope(isolate);
5153
v8::HandleScope handle_scope(isolate);
5254

@@ -73,6 +75,7 @@ std::optional<std::string> JSONParser::GetTopLevelStringField(
7375

7476
std::optional<bool> JSONParser::GetTopLevelBoolField(std::string_view field) {
7577
Isolate* isolate = isolate_.get();
78+
v8::Locker locker(isolate);
7679
v8::Isolate::Scope isolate_scope(isolate);
7780
v8::HandleScope handle_scope(isolate);
7881

@@ -105,6 +108,8 @@ std::optional<bool> JSONParser::GetTopLevelBoolField(std::string_view field) {
105108
std::optional<JSONParser::StringDict> JSONParser::GetTopLevelStringDict(
106109
std::string_view field) {
107110
Isolate* isolate = isolate_.get();
111+
v8::Locker locker(isolate);
112+
v8::Isolate::Scope isolate_scope(isolate);
108113
v8::HandleScope handle_scope(isolate);
109114
Local<Context> context = context_.Get(isolate);
110115
Local<Object> content_object = content_.Get(isolate);

0 commit comments

Comments
 (0)