From 83868d9b4cfc2259dad94c8de72f03f918995cfd Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 20 Sep 2012 11:22:12 +0200 Subject: [PATCH] src/data/data-out.c: Added assertion to catch negative values 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/data-out.c b/src/data/data-out.c index 2a0dd0a195..10ca4ede77 100644 --- a/src/data/data-out.c +++ b/src/data/data-out.c @@ -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; } -- 2.30.2