Skip to content

Commit b669db4

Browse files
committed
fix stoi error
1 parent cde7b09 commit b669db4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/inspector_io.cc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,17 @@ void InspectorIoDelegate::MessageReceived(int session_id,
366366
GetTargetSessionId(message);
367367
std::shared_ptr<MainThreadHandle> worker = nullptr;
368368
int merged_session_id = session_id;
369-
if (!target_session_id_str->empty()) {
370-
int target_session_id = std::stoi(*target_session_id_str);
371-
worker =
372-
protocol::TargetAgent::target_session_id_worker_map_[target_session_id];
373-
if (worker) {
374-
merged_session_id += target_session_id << 16;
369+
if (target_session_id_str) {
370+
bool is_number = std::all_of(target_session_id_str->begin(),
371+
target_session_id_str->end(),
372+
::isdigit);
373+
if (is_number) {
374+
int target_session_id = std::stoi(*target_session_id_str);
375+
worker = protocol::TargetAgent::target_session_id_worker_map_
376+
[target_session_id];
377+
if (worker) {
378+
merged_session_id += target_session_id << 16;
379+
}
375380
}
376381
}
377382

0 commit comments

Comments
 (0)