Skip to content

Commit

Permalink
Merge pull request #78 from iaincalderfh/nilpointerfix
Browse files Browse the repository at this point in the history
Nil pointer dereference in LockedResourceManager v1.2.0
  • Loading branch information
raffaelespazzoli authored Oct 27, 2021
2 parents c1c3655 + f1e80d0 commit f7e7dec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/util/lockedresourcecontroller/locked-resource-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (lrm *LockedResourceManager) GetPatches() []lockedpatch.LockedPatch {

// SetResources set the resources to be enforced. Can be called only when the LockedResourceManager is stopped.
func (lrm *LockedResourceManager) SetResources(resources []lockedresource.LockedResource) error {
if lrm.stoppableManager.IsStarted() {
if lrm.stoppableManager != nil && lrm.stoppableManager.IsStarted() {
return errors.New("cannot set resources while enforcing is on")
}
err := lrm.validateLockedResources(resources)
Expand All @@ -87,7 +87,7 @@ func (lrm *LockedResourceManager) SetResources(resources []lockedresource.Locked

// SetPatches set the patches to be enforced. Can be called only when the LockedResourceManager is stopped.
func (lrm *LockedResourceManager) SetPatches(patches []lockedpatch.LockedPatch) error {
if lrm.stoppableManager.IsStarted() {
if lrm.stoppableManager != nil && lrm.stoppableManager.IsStarted() {
return errors.New("cannot set resources while enforcing is on")
}
// verifyPatchID Uniqueness
Expand All @@ -112,7 +112,7 @@ func (lrm *LockedResourceManager) SetPatches(patches []lockedpatch.LockedPatch)

// IsStarted returns whether the LockedResourceManager is started
func (lrm *LockedResourceManager) IsStarted() bool {
return lrm.stoppableManager.IsStarted()
return lrm.stoppableManager != nil && lrm.stoppableManager.IsStarted()
}

// Start starts the LockedResourceManager
Expand Down

0 comments on commit f7e7dec

Please sign in to comment.