Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions native/cocos/bindings/jswrapper/v8/ScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,11 +1184,12 @@ void ScriptEngine::removeUnhandledPromise(v8::Local<v8::Promise> promise) {
// Remove handled promises from the list
SE_ASSERT(promise->GetIsolate() == _isolate, "Wrong isolate");
auto *isolate = promise->GetIsolate();
for (auto it = _unhandledPromises.begin(); it != _unhandledPromises.end(); ++it) {
v8::Local<v8::Promise> const unhandledPromise = std::get<0>(*it).Get(isolate);
if (unhandledPromise == promise) {
_unhandledPromises.erase(it--);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This crashes if it == _handledPromises.begin()

}
auto const it = std::find_if(_unhandledPromises.begin(), _unhandledPromises.end(), [&](auto const &p) {
v8::Local<v8::Promise> const unhandledPromise = std::get<0>(p).Get(isolate);
return unhandledPromise == promise;
});
if (it != _unhandledPromises.end()) {
_unhandledPromises.erase(it);
}
}

Expand Down
Loading