From 42ae2779bb9dc605cce0e4b2b445caef19085be6 Mon Sep 17 00:00:00 2001 From: 4bb4 <67376761+4bb4@users.noreply.github.com> Date: Sun, 9 Aug 2020 13:56:09 +0200 Subject: [PATCH] Added a safeguard against empty vector plotting, this would segfault --- src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 4b23e1c..9dc85d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -226,6 +226,10 @@ impl PlotLine { /// Plot a line. Use this in closures passed to [`Plot::build()`](struct.Plot.html#method.build) pub fn plot(&self, x: &Vec, y: &Vec) { + // If there is no data to plot, we stop here + if x.len().min(y.len()) == 0 { + return; + } unsafe { implot_sys::ImPlot_PlotLinedoublePtrdoublePtr( im_str!("{}", self.label).as_ptr() as *const i8,