src/data/data-out.c: Added assertion to catch negative values
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 20 Sep 2012 09:22:12 +0000 (11:22 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 20 Sep 2012 09:22:12 +0000 (11:22 +0200)
If the contents of string does not contain a '.', then integer_digits
will end up negative, thus causing a crash later.  This change adds
an assertion to catch this condition and thus make the diagnosis easier
should it ever occur.

src/data/data-out.c

index 2a0dd0a19528bab246f1366963189ae82526c925..10ca4ede77f9e4fbe742927ad80a9fce4471d444 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 >= 0);
   r->negative = number < 0;
 }