Displaying 1 result from an estimated 1 matches for "long_abs".
2013 Jan 08
0
[PATCH] avoid undefined behavior in fmt_scaled()
...2013-01-08 12:18:29.883527421 -0500
@@ -196,12 +196,16 @@
unsigned int i;
unit_type unit = NONE;
+ /* Not every negative long long has a positive representation. */
+ if (number == LLONG_MIN) {
+ errno = ERANGE;
+ return -1;
+ }
+
abval = (number < 0LL) ? -number : number; /* no long long_abs yet */
- /* Not every negative long long has a positive representation.
- * Also check for numbers that are just too darned big to format
- */
- if (abval < 0 || abval / 1024 >= scale_factors[SCALE_LENGTH-1]) {
+ /* Check for numbers that are just too darned big to format. */
+ if (abval /...