From 09e801f40034421a651c5a7d3837b75b2a22a31d Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 6 Feb 2013 11:19:23 +0300 Subject: [PATCH] ranges: don't allow inverted ranges When the min is more than max that's bogus information, don't save it. Part of the problem why we even have to deal with this is that smatch_math.c is buggy and incomplete. I changed alloc_whole_range() as well to handle void types. Those have a size of -2 and cause the min to be greater than the max. It causes an endless loop. Signed-off-by: Dan Carpenter --- smatch_ranges.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/smatch_ranges.c b/smatch_ranges.c index 79c9b550..81ba561c 100644 --- a/smatch_ranges.c +++ b/smatch_ranges.c @@ -197,13 +197,16 @@ struct range_list *alloc_rl(sval_t min, sval_t max) { struct range_list *rl = NULL; + if (sval_cmp(min, max) > 0) + return alloc_whole_rl(min.type); + add_range(&rl, min, max); return rl; } struct range_list *alloc_whole_rl(struct symbol *type) { - if (!type) + if (!type || type_positive_bits(type) < 0) type = &llong_ctype; return alloc_rl(sval_type_min(type), sval_type_max(type)); -- 2.11.4.GIT