Skip to content

Commit f1571ef

Browse files
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: hemang1404 <hemangsharrma@gmail.com> Signed-off-by: ishaanxgupta <ishaankone@gmail.com>
1 parent 40f09f2 commit f1571ef

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.github/contributors.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ users:
5353
ishaanxgupta:
5454
name: Ishaan Gupta
5555
email: ishaankone@gmail.com
56+
hemang1404:
57+
name: Hemang Sharrma
58+
email: hemangsharrma@gmail.com
5659
ilp-sys:
5760
name: Jiwoo Ahn
5861
email: ikwydls1314@gmail.com

pkg/unikontainers/unikontainers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ func (u *Unikontainer) executeHooksConcurrently(name string, hooks []specs.Hook,
777777
uniklog.WithFields(logrus.Fields{
778778
"id": u.State.ID,
779779
"name": name,
780-
"path": hooks[i].Path,
781-
"args": hooks[i].Args,
780+
"path": h.Path,
781+
"args": h.Args,
782782
"error": err,
783783
}).Error("Executing hook failed")
784784
errChan <- err

0 commit comments

Comments
 (0)