[PATCH] missing va_end() in some IO functions (gmp 6.1.2)

Vincent Lefevre vincent at vinc17.net
Wed Mar 13 12:36:11 UTC 2019

On 2019-03-13 12:16:29 +0100, Jakub Martisko wrote:
> I believe there are some missing va_end() calls in some of the IO
> functions of GMP 6.1.2. See attached patch for details.

A few notes about your patch...

--- a/printf/snprntffuns.c
+++ b/printf/snprntffuns.c
@@ -85,6 +85,7 @@ gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt,
       d->buf += step;

       if (ret != avail-1)
+        va_end(ap);
         return ret;

This one is incorrect since the "return ret;" will no longer be
in the "if" branch.

Moreover, the va_end(3) man page says:

  On  some  systems,  va_end  contains  a  closing  '}' matching a '{' in
  va_start, so that both macros must occur in the same function, and in a
  way that allows this.

Thus even

       if (ret != avail-1)
           return ret;

would not work on such systems.

Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-bugs mailing list