epezent / implot

Immediate Mode Plotting
MIT License
4.71k stars 521 forks source link

Crash when rendering shaded plots with no data point [v0.16] #536

Open Nahor opened 10 months ago

Nahor commented 10 months ago

Implot v0.16 causes a crash when displaying a shaded plot with no data points.

For instance, in the "Demo_ShadedPlots" sample, change line 379 from:

ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,1001);

to

ImPlot::PlotShaded("Uncertain Data",xs,ys1,ys2,0);

Then run the application, open the implot demo window and expand the "Shaded plots" section => crash.

When doing the same thing with the line plots (e.g. line 380) instead, there is no crash.

Stracktrace in VS2022:

app.exe!ImPlot::IndexData<float>(const float * data, int idx, int count, int offset, int stride) Line 495
app.exe!ImPlot::IndexerIdx<float>::operator()<int>(int idx) Line 512
app.exe!ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>::operator()<int>(int idx) Line 562
app.exe!ImPlot::RendererShaded<ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>>::Render(ImDrawList & draw_list, const ImRect & cull_rect, int prim) Line 1282
app.exe!ImPlot::RenderPrimitivesEx<ImPlot::RendererShaded<ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>>>(const ImPlot::RendererShaded<ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>> & renderer, ImDrawList & draw_list, const ImRect & cull_rect) Line 1391
app.exe!ImPlot::RenderPrimitives2<ImPlot::RendererShaded,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,unsigned int>(const ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>> & getter1, const ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>> & getter2, unsigned int <args_0>) Line 1411
app.exe!ImPlot::PlotShadedEx<ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>,ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>>>(const char * label_id, const ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>> & getter1, const ImPlot::GetterXY<ImPlot::IndexerIdx<float>,ImPlot::IndexerIdx<float>> & getter2, int flags) Line 1754
app.exe!ImPlot::PlotShaded<float>(const char * label_id, const float * xs, const float * ys1, const float * ys2, int count, int flags, int offset, int stride) Line 1786
app.exe!ImPlot::Demo_ShadedPlots() Line 380
app.exe!ImPlot::DemoHeader(const char * label, void(*)() demo) Line 2143
app.exe!ImPlot::ShowDemoWindow(bool * p_open) Line 2206
[...]
kingpeterking commented 9 months ago

Yep got the same