[virt-tools-list] [vhostmd PATCH 09/18] util: Add missing call to va_end

Jim Fehlig jfehlig at suse.com
Wed Jan 15 22:07:44 UTC 2020


>From coverity scan

Error: VARARGS (CWE-237):
vhostmd-1.1/vhostmd/util.c:209: va_init: Initializing va_list "argptr".
vhostmd-1.1/vhostmd/util.c:218: missing_va_end: va_end was not called for "argptr".
  216|           grow_size = (count > 1000) ? count : 1000;
  217|           if (buffer_grow(buf, grow_size) < 0)
  218|->             return;
  219|
  220|           size = buf->size - buf->use - 1;

Error: VARARGS (CWE-237):
vhostmd-1.1/vhostmd/util.c:209: va_init: Initializing va_list "argptr".
vhostmd-1.1/vhostmd/util.c:226: missing_va_end: va_end was not called for "argptr".
  224|       buf->use += count;
  225|       buf->content[buf->use] = '\0';
  226|-> }
  227|
  228|   /*

Signed-off-by: Jim Fehlig <jfehlig at suse.com>
---
 vhostmd/util.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/vhostmd/util.c b/vhostmd/util.c
index 5747f16..1f9545b 100644
--- a/vhostmd/util.c
+++ b/vhostmd/util.c
@@ -214,13 +214,16 @@ void vu_buffer_vsprintf(vu_buffer *buf, const char *format, ...)
         va_end(locarg);
 
         grow_size = (count > 1000) ? count : 1000;
-        if (buffer_grow(buf, grow_size) < 0)
+        if (buffer_grow(buf, grow_size) < 0) {
+            va_end(argptr);
             return;
+        }
 
         size = buf->size - buf->use - 1;
         va_copy(locarg, argptr);
     }
     va_end(locarg);
+    va_end(argptr);
     buf->use += count;
     buf->content[buf->use] = '\0';
 }
-- 
2.16.4





More information about the virt-tools-list mailing list