From 81b964d4a4cd471904d77a1a708c9a983c5d260a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Senart?= Date: Tue, 29 Aug 2023 18:18:30 +0100 Subject: [PATCH] cmd/ingest: fix nil pointer deref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the previous block returns an error, ingestRes may be nil, which caused a panic. Signed-off-by: Tomás Senart --- internal/cmd/ingest/ingest.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/cmd/ingest/ingest.go b/internal/cmd/ingest/ingest.go index e1e9e98..1d30d66 100644 --- a/internal/cmd/ingest/ingest.go +++ b/internal/cmd/ingest/ingest.go @@ -299,7 +299,11 @@ func run(ctx context.Context, opts *options, flushEverySet bool) error { } else { ingestRes, err = ingestReader(ctx, client, r, typ, opts) } - res.Add(ingestRes) + + // Error handling below, so we need to check for nil. + if ingestRes != nil { + res.Add(ingestRes) + } if err != nil && !errors.Is(err, context.Canceled) { _ = rc.Close()