From 0d4834f3c39230c8213c796b4e8b9dbee1d9ceb3 Mon Sep 17 00:00:00 2001 From: Andrei Alexandru Date: Wed, 14 Aug 2024 17:02:53 +0300 Subject: [PATCH] fix: cluster-registry-sync-manager nil pointer dereference (#219) Co-authored-by: aalexand --- pkg/sync/manager/controller.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/sync/manager/controller.go b/pkg/sync/manager/controller.go index 87415ea..f816ca3 100644 --- a/pkg/sync/manager/controller.go +++ b/pkg/sync/manager/controller.go @@ -325,9 +325,12 @@ func (c *SyncController) hasDifferentHash(object runtime.Object) bool { instance := object.(*registryv1alpha1.ClusterSync) oldHash := instance.Status.SyncedDataHash - newHash := ptr.To(hash(instance.Status.SyncedData)) - return *oldHash != *newHash + if oldHash == nil || instance.Status.SyncedData == nil { + return true + } + + return *oldHash != hash(instance.Status.SyncedData) } func (c *SyncController) updateStatus(ctx context.Context, instance *registryv1alpha1.ClusterSync) error {