Parcourir la source

lib/ur: Prevent panic when blocksResult is nil (ref #7495) (#7515)

Simon Frei il y a 4 ans
Parent
commit
6b25eb2e79
1 fichiers modifiés avec 5 ajouts et 5 suppressions
  1. 5 5
      lib/ur/usage_report.go

+ 5 - 5
lib/ur/usage_report.go

@@ -426,12 +426,12 @@ func CpuBench(ctx context.Context, iterations int, duration time.Duration, useWe
 			perf = v
 		}
 	}
-	if blocksResult == nil {
-		// not looking at the blocksResult makes it unused from a static
-		// analysis / compiler standpoint...
-		panic("blocksResult should have been set by benchmark loop")
+	// not looking at the blocksResult makes it unused from a static
+	// analysis / compiler standpoint...
+	// blocksResult may be nil at this point if the context is cancelled
+	if blocksResult != nil {
+		blocksResult = nil
 	}
-	blocksResult = nil
 	return perf
 }