Prevent later accesses to unallocated memory (#907)

A pointer to dtype is stored in the dict forever.
dtype is stack-allocated while the dict created is global.
The dict (and the pointer to dtype in it) will live past the lifetime of
dtype.
clusterManagerLinkDictType is a global object that has the same values
as dtype.

Signed-off-by: Salvatore Mesoraca <salvatore.mesoraca@aiven.io>
This commit is contained in:
Salvatore Mesoraca 2024-08-14 18:03:27 +02:00 committed by GitHub
parent 131857e80a
commit 68b2270947
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6401,10 +6401,7 @@ static int clusterManagerCheckCluster(int quiet) {
clusterManagerOnError(err);
result = 0;
if (do_fix /* && result*/) {
dictType dtype = clusterManagerDictType;
dtype.keyDestructor = dictSdsDestructor;
dtype.valDestructor = dictListDestructor;
clusterManagerUncoveredSlots = dictCreate(&dtype);
clusterManagerUncoveredSlots = dictCreate(&clusterManagerLinkDictType);
int fixed = clusterManagerFixSlotsCoverage(slots);
if (fixed > 0) result = 1;
}