mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Fix implicit memory aliasing in for loop
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -34,6 +34,7 @@ var _ oci.SpecModifier = (*fromCDISpec)(nil)
|
||||
// Modify applies the mofiications defined by the raw CDI spec to the incomming OCI spec.
|
||||
func (m fromCDISpec) Modify(spec *specs.Spec) error {
|
||||
for _, device := range m.cdiSpec.Devices {
|
||||
device := device
|
||||
cdiDevice := cdi.Device{
|
||||
Device: &device,
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ func (m nvidiaContainerRuntimeHookRemover) Modify(spec *specs.Spec) error {
|
||||
var newPrestart []specs.Hook
|
||||
|
||||
for _, hook := range spec.Hooks.Prestart {
|
||||
hook := hook
|
||||
if isNVIDIAContainerRuntimeHook(&hook) {
|
||||
m.logger.Debugf("Removing hook %v", hook)
|
||||
continue
|
||||
|
||||
@@ -48,6 +48,7 @@ func (m stableRuntimeModifier) Modify(spec *specs.Spec) error {
|
||||
// If an NVIDIA Container Runtime Hook already exists, we don't make any modifications to the spec.
|
||||
if spec.Hooks != nil {
|
||||
for _, hook := range spec.Hooks.Prestart {
|
||||
hook := hook
|
||||
if isNVIDIAContainerRuntimeHook(&hook) {
|
||||
m.logger.Infof("Existing nvidia prestart hook (%v) found in OCI spec", hook.Path)
|
||||
return nil
|
||||
|
||||
@@ -150,6 +150,8 @@ func TestAddHookModifier(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
logHook.Reset()
|
||||
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user