summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate
diff options
context:
space:
mode:
authorOndra Machacek <omachace@redhat.com>2022-01-20 15:08:29 +0100
committerOndra Machacek <omachace@redhat.com>2022-01-21 10:01:32 +0100
commit9d815707e226b432ebd38682826a96e7a00cb46e (patch)
tree81d4e7148d42eb7cbf532fc6423627be3044d415 /pkg/specgen/generate
parent1d6e154a73505cd0366cdeec7cc8582dd3ac2191 (diff)
downloadpodman-9d815707e226b432ebd38682826a96e7a00cb46e.tar.gz
podman-9d815707e226b432ebd38682826a96e7a00cb46e.tar.bz2
podman-9d815707e226b432ebd38682826a96e7a00cb46e.zip
Fix nil pointer dereference for configmap optional
This PR fixes nil pointer dereference for configmap optional parameter. When optional parameter is not passed, the code tried to acces the parameter which caused nil pointer dereference. Signed-off-by: Ondra Machacek <omachace@redhat.com>
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r--pkg/specgen/generate/kube/volume.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go
index e52d70092..01f731b60 100644
--- a/pkg/specgen/generate/kube/volume.go
+++ b/pkg/specgen/generate/kube/volume.go
@@ -122,7 +122,7 @@ func VolumeFromConfigMap(configMapVolumeSource *v1.ConfigMapVolumeSource, config
if configMap == nil {
// If the volumeSource was optional, move on even if a matching configmap wasn't found
- if *configMapVolumeSource.Optional {
+ if configMapVolumeSource.Optional != nil && *configMapVolumeSource.Optional {
kv.Source = configMapVolumeSource.Name
kv.Optional = *configMapVolumeSource.Optional
return kv, nil