1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-17 12:03:07 +01:00

Fix #5496: Attempting to log into servers results in crash

Caused by the user not having the required 'official' objects. This was because the network was being closed during a network update. Disposed memory would then be accessed later in the update loop.

To fix this, a lock has been added to Close() so that it can be deferred to the end of Update(). This isn't particularly nice, but the whole of network will need redesigning to fix this properly for all potentical scenarios where Close() can be called.
This commit is contained in:
Ted John
2017-06-06 20:05:41 +01:00
parent 430ab2db5c
commit 1e9f9790ae
5 changed files with 44 additions and 11 deletions

View File

@@ -717,18 +717,28 @@ bool IsObjectCustom(const ObjectRepositoryItem * object)
extern "C"
{
rct_object_entry * object_list_find(rct_object_entry * entry)
const rct_object_entry * object_list_find(rct_object_entry * entry)
{
IObjectRepository * objRepo = GetObjectRepository();
const ObjectRepositoryItem * item = objRepo->FindObject(entry);
return (rct_object_entry *)&item->ObjectEntry;
const rct_object_entry * result = nullptr;
auto objRepo = GetObjectRepository();
auto item = objRepo->FindObject(entry);
if (item != nullptr)
{
result = &item->ObjectEntry;
}
return result;
}
rct_object_entry * object_list_find_by_name(const char * name)
const rct_object_entry * object_list_find_by_name(const char * name)
{
IObjectRepository * objRepo = GetObjectRepository();
const ObjectRepositoryItem * item = objRepo->FindObject(name);
return (rct_object_entry *)&item->ObjectEntry;
const rct_object_entry * result = nullptr;
auto objRepo = GetObjectRepository();
auto item = objRepo->FindObject(name);
if (item != nullptr)
{
result = &item->ObjectEntry;
}
return result;
}
void object_list_load()