1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Fix nullptr dereference in IPC::isCurrentOwner

It would only trigger when multiple instances where running in parallel,
with one having enough privilege to block the other from accessing the shared memory (e.g. root)
This commit is contained in:
tux3 2015-04-24 15:38:21 +02:00
parent 9dedd22bb2
commit 66314bc38d
No known key found for this signature in database
GPG Key ID: 7E086DD661263264

View File

@ -134,8 +134,14 @@ bool IPC::isCurrentOwner()
{
if (globalMemory.lock())
{
/// TODO: Segfault on exit on "mov rdx,QWORD PTR [rax]" w/ rax=0.
bool isOwner = ((*(uint64_t*)globalMemory.data()) == globalId);
void* data = globalMemory.data();
if (!data)
{
qWarning() << "IPC: isCurrentOwner failed to access the memory, returning false";
globalMemory.unlock();
return false;
}
bool isOwner = ((*(uint64_t*)data) == globalId);
globalMemory.unlock();
return isOwner;
}