summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-02-19 19:28:14 +0100
committerMarek Olšák <[email protected]>2017-02-22 20:26:39 +0100
commit31e7ba71249f3e493e65bd497d40eca3b15147be (patch)
treed730eabb1fa7e790144144a116eb92f59037e79d /src
parent24847dd1b5327d40069a7b72e8286187675f99b2 (diff)
gallium/hud: prevent an infinite loop
v2: use UINT64_MAX / 11 Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index aaa52d5b173..c44f8c01a31 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -731,9 +731,10 @@ hud_pane_set_max_value(struct hud_pane *pane, uint64_t value)
* hard-to-read numbers like 1.753.
*/
- /* Find the left-most digit. */
+ /* Find the left-most digit. Make sure exp10 * 10 and fixup_bytes doesn't
+ * overflow. (11 is safe) */
exp10 = 1;
- for (i = 0; value > 9 * exp10; i++) {
+ for (i = 0; exp10 <= UINT64_MAX / 11 && exp10 * 9 < value; i++) {
exp10 *= 10;
fixup_bytes(pane->type, i + 1, &exp10);
}