diff --git a/unpacker.go b/unpacker.go
index <HASH>..<HASH> 100644
--- a/unpacker.go
+++ b/unpacker.go
@@ -178,13 +178,13 @@ EachLayer:
 				fetchC[i] = make(chan struct{})
 			}
 
-			go func() {
+			go func(i int) {
 				err := u.fetch(ctx, h, layers[i:], fetchC)
 				if err != nil {
 					fetchErr <- err
 				}
 				close(fetchErr)
-			}()
+			}(i)
 		}
 
 		select {
unpacker: Fix data race and possible data corruption