Skip to content

Commit d5702be

Browse files
committed
Core - ClientAdapter::OnProcessMessageReceived add nullptr checks
Follow up to #3573
1 parent 842429a commit d5702be

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

CefSharp.Core.Runtime/Internals/ClientAdapter.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,11 @@ namespace CefSharp
11411141

11421142
auto objectRepository = browserAdapter->JavascriptObjectRepository;
11431143

1144+
if (objectRepository == nullptr)
1145+
{
1146+
return true;
1147+
}
1148+
11441149
auto callbackId = GetInt64(argList, 0);
11451150
auto objectNames = argList->GetList(1);
11461151

@@ -1173,6 +1178,11 @@ namespace CefSharp
11731178

11741179
auto objectRepository = browserAdapter->JavascriptObjectRepository;
11751180

1181+
if (objectRepository == nullptr)
1182+
{
1183+
return true;
1184+
}
1185+
11761186
auto boundObjects = argList->GetList(0);
11771187
auto objs = gcnew List<Tuple<String^, bool, bool>^>(boundObjects->GetSize());
11781188
for (size_t i = 0; i < boundObjects->GetSize(); i++)
@@ -1346,6 +1356,15 @@ namespace CefSharp
13461356
}
13471357

13481358
auto callbackFactory = browserAdapter->JavascriptCallbackFactory;
1359+
auto methodRunnerQueue = browserAdapter->MethodRunnerQueue;
1360+
1361+
//Dispose is called on a different thread, so there's a chance
1362+
//dispose is called after our IsDisposed checks, make sure we have
1363+
//actual references.
1364+
if (callbackFactory == nullptr || methodRunnerQueue == nullptr)
1365+
{
1366+
return true;
1367+
}
13491368

13501369
auto frameId = frame->GetIdentifier();
13511370
auto objectId = GetInt64(argList, 0);
@@ -1358,7 +1377,7 @@ namespace CefSharp
13581377
methodInvocation->Parameters->Add(DeserializeObject(arguments, i, callbackFactory));
13591378
}
13601379

1361-
browserAdapter->MethodRunnerQueue->Enqueue(methodInvocation);
1380+
methodRunnerQueue->Enqueue(methodInvocation);
13621381

13631382
handled = true;
13641383
}

0 commit comments

Comments
 (0)