mirror of
https://github.com/containers/podman.git
synced 2025-10-15 10:16:28 +08:00
pkg/env.Join(): don't modify passed-in maps
Make sure that env.Join() doesn't modify passed-in maps by cloning them and using only the clones. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
5
pkg/env/env.go
vendored
5
pkg/env/env.go
vendored
@ -8,6 +8,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
const whiteSpaces = " \t"
|
||||
@ -50,8 +52,9 @@ func Map(slice []string) map[string]string {
|
||||
// Join joins the two environment maps with override overriding base.
|
||||
func Join(base map[string]string, override map[string]string) map[string]string {
|
||||
if len(base) == 0 {
|
||||
return override
|
||||
return maps.Clone(override)
|
||||
}
|
||||
base = maps.Clone(base)
|
||||
for k, v := range override {
|
||||
base[k] = v
|
||||
}
|
||||
|
Reference in New Issue
Block a user