From: John Darrington Date: Thu, 20 Sep 2012 09:22:12 +0000 (+0200) Subject: src/data/data-out.c: Added assertion to catch negative values X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83868d9b4cfc2259dad94c8de72f03f918995cfd;p=pspp 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. --- 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; }