diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-24 10:30:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-24 10:30:33 +0300 |
| commit | 03136db76ee7b60a3570f6c20c416ae9f53ec3ae (patch) | |
| tree | ed7fd86b7cd1433dc56497eea7644115eeaf0133 | |
| parent | c2528014a6c621dca9d46eb70a13db9038e8e5d0 (diff) | |
rpn: use GetCoolMetric() instead of ignored-error Find("Cool")
resultMetricForAdd silently ignored the error from
GetMetricRegistry().Find("Cool"), which could propagate a nil
*Metric if Cool were absent, risking nil pointer dereference.
Replace with GetCoolMetric() which is guaranteed non-nil.
| -rw-r--r-- | internal/rpn/operations_metric.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/internal/rpn/operations_metric.go b/internal/rpn/operations_metric.go index a9f91cc..4809ce1 100644 --- a/internal/rpn/operations_metric.go +++ b/internal/rpn/operations_metric.go @@ -50,8 +50,7 @@ func resultMetricForAdd(metrics []*Metric) *Metric { if len(metrics) > 0 && metrics[0] != nil { return metrics[0] } - m, _ := GetMetricRegistry().Find("Cool") - return m + return GetCoolMetric() } // categoriesCompatible checks if two metrics are compatible for arithmetic. |
