projects
/
mesa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
24847dd
)
gallium/hud: prevent an infinite loop
author
Marek Olšák
<marek.olsak@amd.com>
Sun, 19 Feb 2017 18:28:14 +0000
(19:28 +0100)
committer
Marek Olšák
<marek.olsak@amd.com>
Wed, 22 Feb 2017 19:26:39 +0000
(20:26 +0100)
v2: use UINT64_MAX / 11
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/hud/hud_context.c
patch
|
blob
|
history
diff --git
a/src/gallium/auxiliary/hud/hud_context.c
b/src/gallium/auxiliary/hud/hud_context.c
index aaa52d5b173baf442b46d881af86127f956ab7fc..c44f8c01a31fd404288c34c09833ce0116bd8abf 100644
(file)
--- 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);
}