jrhouston/k8slock

Copy and paste error in `lock()`?

Opened this issue · 0 comments

k8slock/locker.go

Lines 187 to 192 in 6f294b1

lease.Spec.HolderIdentity = pointer.String(l.clientID)
if lease.Spec.LeaseTransitions != nil {
lease.Spec.LeaseTransitions = pointer.Int32((*lease.Spec.LeaseTransitions) + 1)
} else {
lease.Spec.LeaseTransitions = pointer.Int32((*lease.Spec.LeaseTransitions) + 1)
}

Here, the code checks if lease.Spec.LeaseTransitions is nil but the if-else branches are identical.

pointer.Int32((*lease.Spec.LeaseTransitions) + 1)

will segfault with a nil lease.Spec.LeaseTransitions