This patch changes the output for the arguments (UINT64_MAX, 4, 1, 0,
N2S_NONE, "18.4") from "18.4(null)" into "18.4".
This patch fixes the following Coverity complaint:
CID 169307 (#1 of 1): Out-of-bounds read (OVERRUN)
27. overrun-local: Overrunning array of 6 8-byte elements at element
index 6 (byte offset 55) by dereferencing pointer unitprefix + post_index.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
post_index++;
}
+ if (post_index >= ARRAY_SIZE(sistr))
+ post_index = 0;
+
/*
* If no modulo, then we're done.
*/
if (modulo == -1U) {
done:
- if (post_index >= ARRAY_SIZE(sistr))
- post_index = 0;
-
if (asprintf(&buf, "%llu%s%s", (unsigned long long) num,
unitprefix[post_index], unitstr[units]) < 0)
buf = NULL;