From fc30620cdb11b011ee396222795af415feda8b03 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 19 Aug 2024 09:34:55 -0400 Subject: [PATCH] Do not segfault on hard stop Podman machine on MAC can segfault on hard stop. Fixes: 23654 Signed-off-by: Daniel J Walsh --- pkg/machine/apple/vfkit/helper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/machine/apple/vfkit/helper.go b/pkg/machine/apple/vfkit/helper.go index 47a3c98bf6..cc3a22efb4 100644 --- a/pkg/machine/apple/vfkit/helper.go +++ b/pkg/machine/apple/vfkit/helper.go @@ -83,7 +83,9 @@ func (vf *Helper) stateChange(newState rest.StateChange) error { } payload := bytes.NewReader(b) serverResponse, err := vf.post(vf.Endpoint+state, payload) - _ = serverResponse.Body.Close() + if err == nil { + _ = serverResponse.Body.Close() + } return err }