From bca4b7111bf5a51276345911cead4e6e16e59aaf Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 4 Feb 2022 20:47:11 -0800 Subject: [PATCH] [glass] Fix PlotSeries::SetSource() (#3991) This can be called in a delayed manner, so it's possible for m_size to already be at maximum, which results in writing past the end of the array. Instead, just call AppendValue(). --- glass/src/lib/native/cpp/other/Plot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glass/src/lib/native/cpp/other/Plot.cpp b/glass/src/lib/native/cpp/other/Plot.cpp index 2d7fdf056a..9af2da70cb 100644 --- a/glass/src/lib/native/cpp/other/Plot.cpp +++ b/glass/src/lib/native/cpp/other/Plot.cpp @@ -246,7 +246,7 @@ void PlotSeries::SetSource(DataSource* source) { m_source = source; // add initial value - m_data[m_size++] = ImPlotPoint{wpi::Now() * 1.0e-6, source->GetValue()}; + AppendValue(source->GetValue(), 0); m_newValueConn = source->valueChanged.connect_connection( [this](double value, uint64_t time) { AppendValue(value, time); });