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

Jakub Martisko jamartis at redhat.com
Wed Mar 13 11:16:29 UTC 2019


Hello,

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.

Thanks,
Jakub
-------------- next part --------------
>From d755dd08db4962ba57608d2395d9e0885fe44c07 Mon Sep 17 00:00:00 2001
From: rpm-build <rpm-build>
Date: Wed, 13 Mar 2019 11:52:39 +0100
Subject: [PATCH] Fix: call in several IO functions va_end()

---
 printf/doprnt.c      | 3 +++
 printf/snprntffuns.c | 2 ++
 printf/vasprintf.c   | 1 +
 scanf/doscan.c       | 1 +
 4 files changed, 7 insertions(+)

diff --git a/printf/doprnt.c b/printf/doprnt.c
index f3e3e4e..23515f4 100644
--- a/printf/doprnt.c
+++ b/printf/doprnt.c
@@ -619,6 +619,9 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data,
 
  done:
   (*__gmp_free_func) (alloc_fmt, alloc_fmt_size);
+  va_end(ap);
+  va_end(last_ap);
+  va_end(this_ap);
   return retval;
 
  error:
diff --git a/printf/snprntffuns.c b/printf/snprntffuns.c
index 41a7670..ddb4d64 100644
--- 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;
 
       /* probably glibc 2.0.x truncated output, probe for actual size */
@@ -106,6 +107,7 @@ gmp_snprintf_format (struct gmp_snprintf_t *d, const char *fmt,
     }
   while (ret == alloc-1 || ret == -1);
 
+  va_end(ap);
   return ret;
 }
 
diff --git a/printf/vasprintf.c b/printf/vasprintf.c
index 44785da..2c732fe 100644
--- a/printf/vasprintf.c
+++ b/printf/vasprintf.c
@@ -98,6 +98,7 @@ gmp_asprintf_format (struct gmp_asprintf_t *d, const char *fmt,
     }
 
   d->size += ret;
+  va_end(ap);
   return ret;
 }
 
diff --git a/scanf/doscan.c b/scanf/doscan.c
index 47b2270..cf6c67f 100644
--- a/scanf/doscan.c
+++ b/scanf/doscan.c
@@ -764,5 +764,6 @@ __gmp_doscan (const struct gmp_doscan_funs_t *funs, void *data,
 
  done:
   (*__gmp_free_func) (alloc_fmt, alloc_fmt_size);
+  va_end(ap);
   return fields;
 }
-- 
2.21.0



More information about the gmp-bugs mailing list