From 0fdbee79c5fe330402e639c4ee7f040f10b99b19 Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Mon, 4 Dec 2023 14:32:14 +0200 Subject: [PATCH] Image copier: make sure ReportWriter is not nil before accessing When running in Quiet mode, the ReportWriter can be nil causing a crash Signed-off-by: Ygal Blum --- libimage/copier.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libimage/copier.go b/libimage/copier.go index d6acc7325..1edf7d6cb 100644 --- a/libimage/copier.go +++ b/libimage/copier.go @@ -364,11 +364,13 @@ func (c *copier) copy(ctx context.Context, source, destination types.ImageRefere defer cancel() defer timer.Stop() - fmt.Fprintf(c.imageCopyOptions.ReportWriter, - "Pulling image %s inside systemd: setting pull timeout to %s\n", - source.StringWithinTransport(), - time.Duration(numExtensions)*extension, - ) + if c.imageCopyOptions.ReportWriter != nil { + fmt.Fprintf(c.imageCopyOptions.ReportWriter, + "Pulling image %s inside systemd: setting pull timeout to %s\n", + source.StringWithinTransport(), + time.Duration(numExtensions)*extension, + ) + } // From `man systemd.service(5)`: //