From 4f02e65557f5aa516a57a57e606cf7306e105511 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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/machine/apple/vfkit/helper.go b/pkg/machine/apple/vfkit/helper.go index 47a3c98bf6..43a40d6352 100644 --- a/pkg/machine/apple/vfkit/helper.go +++ b/pkg/machine/apple/vfkit/helper.go @@ -83,8 +83,10 @@ func (vf *Helper) stateChange(newState rest.StateChange) error { } payload := bytes.NewReader(b) serverResponse, err := vf.post(vf.Endpoint+state, payload) - _ = serverResponse.Body.Close() - return err + if err != nil { + return err + } + return serverResponse.Body.Close() } func (vf *Helper) Stop(force, wait bool) error {