Added a safeguard against empty vector plotting, this would segfault

This commit is contained in:
4bb4 2020-08-09 13:56:09 +02:00
parent 411086483e
commit 42ae2779bb

View file

@ -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<f64>, y: &Vec<f64>) {
// 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,