data-out.c: Added assertion to avoid out of bounds memory access
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 1 Dec 2012 06:07:13 +0000 (07:07 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 1 Dec 2012 06:07:13 +0000 (07:07 +0100)
This could (has!) happened if the locale is not correctly set

src/data/data-out.c

index 10ca4ede77f9e4fbe742927ad80a9fce4471d444..94e72f668be641d81bedca51660e8716e5773c2b 100644 (file)
@@ -864,6 +864,7 @@ rounder_init (struct rounder *r, double number, int max_decimals)
   r->leading_zeros = strspn (r->string, "0.");
   r->leading_nines = strspn (r->string, "9.");
   r->integer_digits = strchr (r->string, '.') - r->string;
+  assert (r->integer_digits < 64);
   assert (r->integer_digits >= 0);
   r->negative = number < 0;
 }