From 33233e5c77f495a54d21bd949ea9c7d3a9634e87 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 18 Jan 2019 16:05:03 -0800 Subject: examples: Fix boundary condition in ascii_art_dft plotting There was a corner case where the data could be such that the FFT plot symbol selection would cause an out-of-bounds access on the symbols table, and abort the example with an uncaught exception. --- host/examples/ascii_art_dft.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'host/examples') diff --git a/host/examples/ascii_art_dft.hpp b/host/examples/ascii_art_dft.hpp index 19099cbf8..84c008bbf 100644 --- a/host/examples/ascii_art_dft.hpp +++ b/host/examples/ascii_art_dft.hpp @@ -258,7 +258,7 @@ std::string dft_to_plot(const log_pwr_dft_type& dft_, (val - (ref_lvl - dyn_rng)) * (frame.get_plot_h() - 1) / dyn_rng; for (size_t z = 0; z < frame.get_plot_h(); z++) { static const std::string syms(".:!|"); - if (scaled - z > 1) + if (scaled - z >= 1) frame.get_plot(b, z) = syms.at(syms.size() - 1); else if (scaled - z > 0) frame.get_plot(b, z) = syms.at(size_t((scaled - z) * syms.size())); -- cgit v1.2.3