Use explicit index into operations slice in cancelOpsFor()
to avoid mis-indexing when more than one op is removed
This commit is contained in:
1 parent
5635ba1fd0
commit
a7e0f03647
2 files changed
+40
-2
No files matched your search
+4
-2
@@ -126,12 +126,14 @@ func (alloc *Allocator) cancelOps(ops *[]operation) {
|
||||
// if we found any.
|
||||
func (alloc *Allocator) cancelOpsFor(ops *[]operation, ident string) bool {
|
||||
var found bool
|
||||
for i, op := range *ops {
|
||||
if op.ForContainer(ident) {
|
||||
for i := 0; i < len(*ops); {
|
||||
if op := (*ops)[i]; op.ForContainer(ident) {
|
||||
found = true
|
||||
op.Cancel()
|
||||
*ops = append((*ops)[:i], (*ops)[i+1:]...)
|
||||
continue
|
||||
}
|
||||
i++
|
||||
}
|
||||
return found
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user