Skip to content

Commit af3ce32

Browse files
committed
fix(hooks): prevent panic from loop var capture
Fix panic from accessing hooks[i] in async execution after loop. Use captured parameter h instead. Fixes: #418 Co-authored-by: ishaanxgupta <ishaankone@gmail.com> Signed-off-by: hemang1404 <hemangsharrma@gmail.com>
1 parent d5178ae commit af3ce32

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/unikontainers/unikontainers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ func (u *Unikontainer) executeHooksConcurrently(name string, hooks []specs.Hook,
753753
uniklog.WithFields(logrus.Fields{
754754
"id": u.State.ID,
755755
"name": name,
756-
"path": hooks[i].Path,
757-
"args": hooks[i].Args,
756+
"path": h.Path,
757+
"args": h.Args,
758758
"error": err,
759759
}).Error("Executing hook failed")
760760
errChan <- err

0 commit comments

Comments
 (0)