Commit cd3faf9
Dongsu Park
validation: fix nil dereference when handling multierror in hooks_stdin
As `stdinStateCheck()` can return nil for errs, we need to access to
`errs.Error()` only when errs is not nil. So conditionally compose
newError for both cases, errs == nil and errs != nil, to avoid panics
like that:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x4f5a02]
goroutine 1 [running]:
github.com/opencontainers/runtime-tools/vendor/github.com/hashicorp/go-multierror.(*Error).Error(0x0, 0x7dfc20, 0xc420224480)
.../github.com/opencontainers/runtime-tools/vendor/github.com/hashicorp/go-multierror/multierror.go:15 +0x22
main.main()
.../github.com/opencontainers/runtime-tools/validation/hooks_stdin.go:154 +0x11ba
```
Signed-off-by: Dongsu Park <dongsu@kinvolk.io>1 parent 9b65419 commit cd3faf9
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
155 | 161 | | |
156 | 162 | | |
157 | 163 | | |
| |||
0 commit comments