From: Dan Carpenter Date: Mon, 4 Feb 2013 14:25:38 +0000 (+0300) Subject: overflow: fix false positive allocating a void pointer X-Git-Tag: 1.57~14 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/ac067bde67c2e200120380b1e0e093e6bae01e69 overflow: fix false positive allocating a void pointer For a void pointer the bytes is -1. Also if it says we are allocating a negative number of bytes that's probably bogus. Treat it as a large positive by using sval.uvalue instead of sval.value. Signed-off-by: Dan Carpenter --- diff --git a/check_overflow.c b/check_overflow.c index ee4ed316..a0de2e5e 100644 --- a/check_overflow.c +++ b/check_overflow.c @@ -320,9 +320,9 @@ static void db_returns_buf_size(struct expression *expr, int param, char *unused if (!type) return; bytes = bits_to_bytes(type->bit_size); - if (!bytes) + if (bytes <= 0) return; - if (sval.value >= bytes) + if (sval.uvalue >= bytes) return; sm_msg("error: not allocating enough data %d vs %s", bytes, sval_to_str(sval)); }