projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
acc57a6
)
src/data/data-out.c: Added assertion to catch negative values
author
John Darrington
<john@darrington.wattle.id.au>
Thu, 20 Sep 2012 09:22:12 +0000
(11:22 +0200)
committer
John 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
patch
|
blob
|
history
diff --git
a/src/data/data-out.c
b/src/data/data-out.c
index 2a0dd0a19528bab246f1366963189ae82526c925..10ca4ede77f9e4fbe742927ad80a9fce4471d444 100644
(file)
--- 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;
}