dix: resource: protect FakeClientID() from returning 0

Some callers treating XID = 0 as a sign for non-existing resource.
Practically should not happen, but nevertheless adding extra
protection, just in case.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2025-03-10 14:12:48 +01:00
parent eb95982b2a
commit 030b441e21

View File

@ -789,6 +789,12 @@ FakeClientID(int client)
XID id, maxid;
id = clientTable[client].fakeID++;
// extra paranoid protection, because many places expect 0 as
// sign for resource not existing
if (!id)
return FakeClientID(client);
if (id != clientTable[client].endFakeID)
return id;
GetXIDRange(client, TRUE, &id, &maxid);
@ -801,6 +807,10 @@ FakeClientID(int client)
}
clientTable[client].fakeID = id + 1;
clientTable[client].endFakeID = maxid + 1;
if (!id)
return FakeClientID(client);
return id;
}