From 770ca3a624aa265f8c90f8e81302d3b95a0152d9 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Thu, 1 Feb 2024 22:47:11 +0100 Subject: [PATCH] Fix #8253: don't use INVALID_DATAPOINT for a valid value (#11913) --- src/graph_gui.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 34b5c6d52f..49654bc813 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -615,7 +615,13 @@ public: if (c != nullptr) { this->colours[numd] = _colour_gradient[c->colour][6]; for (int j = this->num_on_x_axis, i = 0; --j >= 0;) { - this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j); + if (j >= c->num_valid_stat_ent) { + this->cost[numd][i] = INVALID_DATAPOINT; + } else { + /* Ensure we never assign INVALID_DATAPOINT, as that has another meaning. + * Instead, use the value just under it. Hopefully nobody will notice. */ + this->cost[numd][i] = std::min(GetGraphData(c, j), INVALID_DATAPOINT - 1); + } i++; } }