Skip to content

Commit e811484

Browse files
committed
fix: __runOnMainThread erase iterator before it can be invalidated
1 parent 52b7fa2 commit e811484

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test-app/runtime/src/main/cpp/CallbackHandlers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,13 +687,13 @@ int CallbackHandlers::RunOnMainThreadFdCallback(int fd, int events, void *data)
687687
Local<v8::Function> cb = it->second.callback_.Get(isolate);
688688
v8::Local<v8::Context> context = cb->GetCreationContextChecked();
689689
Context::Scope context_scope(context);
690+
// erase the it here as we're already done with its values and the callback might invalidate the iterator
691+
cache_.erase(it);
690692

691693
v8::TryCatch tc(isolate);
692694

693695
cb->Call(context, context->Global(), 0, nullptr); // ignore JS return value
694696

695-
cache_.erase(it);
696-
697697
if(tc.HasCaught()){
698698
throw NativeScriptException(tc);
699699
}

0 commit comments

Comments
 (0)