Commit af7a902d authored by Rusty Russell's avatar Rusty Russell

tally: don't use SIZE_MAX.

Turns out it's not standard (thanks Samba build farm!)
And the previous test had a hole in it anyway.  This one is more conservative.
parent 532feb88
......@@ -27,8 +27,8 @@ struct tally *tally_new(unsigned buckets)
if (buckets == 0)
buckets = 1;
/* Check for overflow. */
if (buckets && SIZE_MAX / buckets < sizeof(tally->counts[0]))
/* Overly cautious check for overflow. */
if (sizeof(*tally) * buckets / sizeof(*tally) != buckets)
return NULL;
tally = malloc(sizeof(*tally) + sizeof(tally->counts[0])*(buckets-1));
if (tally) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment