From 36d35f7d68ddcda58b32b0334cb855e7b8b670f8 Mon Sep 17 00:00:00 2001 From: Frederic Branczyk Date: Mon, 16 Dec 2024 17:32:09 +0100 Subject: [PATCH] reporter: Fix io.EOF handling The way the if statement was written, if there is an io.EOF error, then we still first try reading the response object, however, in the io.EOF case it's null, therefore the if statement needs to be swapped around so it would never try to read something on the nil pointer if an io.EOF error is returned. --- reporter/parca_reporter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reporter/parca_reporter.go b/reporter/parca_reporter.go index 919890c48a..3248ff1ccc 100644 --- a/reporter/parca_reporter.go +++ b/reporter/parca_reporter.go @@ -617,7 +617,7 @@ func (r *ParcaReporter) reportDataToBackend(ctx context.Context, buf *bytes.Buff if err != nil && err != io.EOF { return err } - if len(resp.Record) == 0 || err == io.EOF { + if err == io.EOF || len(resp.Record) == 0 { // The backend didn't want any more information. return nil }