Handle the case when the number of bins is zero or negative. Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx> --- src/libkshark-model.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libkshark-model.c b/src/libkshark-model.c index 2301b069..44f829d6 100644 --- a/src/libkshark-model.c +++ b/src/libkshark-model.c @@ -97,8 +97,19 @@ static void ksmodel_set_in_range_bining(struct kshark_trace_histo *histo, int64_t corrected_range, delta_range, range = max - min; struct kshark_entry *last; + if (n <= 0) { + histo->n_bins = histo->bin_size = 0; + histo->min = min; + histo->max = max; + + free(histo->bin_count); + free(histo->map); + + return; + } + /* The size of the bin must be >= 1, hence the range must be >= n. */ - if (n == 0 || range < n) { + if (range < n) { range = n; max = min + n; } -- 2.25.1