From f9dacd6e0c62b27f9ef8a2f94e051adf0466b841 Mon Sep 17 00:00:00 2001 From: Patric Stout Date: Sun, 28 Jan 2024 20:51:43 +0100 Subject: [PATCH] Fix: don't use INVALID_DATAPOINT for a valid value --- 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++; } }