diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-22 09:23:57 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-22 09:23:57 +0000 |
commit | 25a521e674cada3fe67998693bcaeb065cfdcf24 (patch) | |
tree | 5cdd0ac5ec4fa028bbafdd29d40a899419a07ea8 | |
parent | 8dac76c3a64062bc0b598d5d47c4cc74353b84ca (diff) | |
download | mpfr-25a521e674cada3fe67998693bcaeb065cfdcf24.tar.gz |
[src/vasprintf.c] With assertions enabled, check that the number of
characters to be written computed in partition_number() corresponds
to what is really written.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11514 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/vasprintf.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/vasprintf.c b/src/vasprintf.c index 075279418..3f6fd8295 100644 --- a/src/vasprintf.c +++ b/src/vasprintf.c @@ -1877,7 +1877,7 @@ static int sprnt_fp (struct string_buffer *buf, mpfr_srcptr p, const struct printf_spec spec) { - int length; + int length, start; struct number_parts np; length = partition_number (&np, p, spec); @@ -1892,6 +1892,8 @@ sprnt_fp (struct string_buffer *buf, mpfr_srcptr p, goto clear_and_exit; } + MPFR_DBGRES (start = buf->len); + /* right justification padding with left spaces */ if (np.pad_type == LEFT && np.pad_size != 0) buffer_pad (buf, ' ', np.pad_size); @@ -1946,6 +1948,8 @@ sprnt_fp (struct string_buffer *buf, mpfr_srcptr p, if (np.pad_type == RIGHT && np.pad_size != 0) buffer_pad (buf, ' ', np.pad_size); + MPFR_ASSERTD (buf->len == -1 || buf->len - start == length); + clear_and_exit: clear_string_list (np.sl); return buf->len == -1 ? -1 : length; |