diff options
author | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2018-02-08 13:07:16 +0100 |
---|---|---|
committer | Marco Bodrato <bodrato@mail.dm.unipi.it> | 2018-02-08 13:07:16 +0100 |
commit | e0abf14b09f5fcb20fa2301a9a0499d3d1c5d11a (patch) | |
tree | de0393324ee06e6aee14a8e2c0243cc6f4536483 | |
parent | 95d89505a623cd743e05ac8b0b30ddcb85091506 (diff) | |
download | gmp-e0abf14b09f5fcb20fa2301a9a0499d3d1c5d11a.tar.gz |
printf/snprntffuns.c: report -1 as an error.
acinclude.m4: Refuse -1 as a normal return value.
-rw-r--r-- | acinclude.m4 | 4 | ||||
-rw-r--r-- | printf/snprntffuns.c | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/acinclude.m4 b/acinclude.m4 index aa91aa11f..2ea5f5aa2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -3729,11 +3729,11 @@ check (const char *fmt, ...) ret = vsnprintf (buf, 4, fmt, ap); - if (strcmp (buf, "hel") != 0) + if (ret == -1 || strcmp (buf, "hel") != 0) return 1; /* allowed return values */ - if (ret != -1 && ret != 3 && ret != 11) + if (ret != 3 && ret != 11) return 2; return 0; diff --git a/printf/snprntffuns.c b/printf/snprntffuns.c index d5d76a29f..562227908 100644 --- a/printf/snprntffuns.c +++ b/printf/snprntffuns.c @@ -75,10 +75,7 @@ gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt, va_copy (ap, orig_ap); ret = vsnprintf (d->buf, avail, fmt, ap); if (ret == -1) - { - ASSERT (strlen (d->buf) == avail-1); - ret = avail-1; - } + return ret; step = MIN (ret, avail-1); d->size -= step; @@ -104,7 +101,7 @@ gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt, ret = vsnprintf (p, alloc, fmt, ap); __GMP_FREE_FUNC_TYPE (p, alloc, char); } - while (ret == alloc-1 || ret == -1); + while (ret == alloc-1); return ret; } |