Patchwork Add missing va_end found by Coverity

login
register
mail settings
Submitter Gary Benson
Date Oct. 10, 2018, 9:32 a.m.
Message ID <1539163961-7279-1-git-send-email-gbenson@redhat.com>
Download mbox | patch
Permalink /patch/29691/
State New
Headers show

Comments

Gary Benson - Oct. 10, 2018, 9:32 a.m.
Hi all,

This commit adds a missing va_end found by Coverity.

Built and regtested on RHEL 7.5 x86_64.

Ok to commit?

Thanks,
Gary

--
gdb/ChangeLog:

	* remote.c (remote_target::remote_send_printf): Add
	missing va_end found by Coverity.
---
 gdb/ChangeLog | 5 +++++
 gdb/remote.c  | 6 +++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
Tom Tromey - Oct. 10, 2018, 1 p.m.
>>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:

Gary> gdb/ChangeLog:

Gary> 	* remote.c (remote_target::remote_send_printf): Add
Gary> 	missing va_end found by Coverity.

Thanks, this is ok.  FWIW I would have been fine with the obvious rule
in this case.

Tom
Gary Benson - Oct. 10, 2018, 2:06 p.m.
Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson <gbenson@redhat.com> writes:
> 
> Gary> gdb/ChangeLog:
> 
> Gary> 	* remote.c (remote_target::remote_send_printf): Add
> Gary> 	missing va_end found by Coverity.
> 
> Thanks, this is ok.

Thank you.

> FWIW I would have been fine with the obvious rule in this case.

Ok, good to know :)

Thanks,
Gary

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 724f41c..c53553a 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -8938,7 +8938,11 @@  remote_target::remote_send_printf (const char *format, ...)
   va_start (ap, format);
 
   rs->buf[0] = '\0';
-  if (vsnprintf (rs->buf, max_size, format, ap) >= max_size)
+  int size = vsnprintf (rs->buf, max_size, format, ap);
+
+  va_end (ap);
+
+  if (size >= max_size)
     internal_error (__FILE__, __LINE__, _("Too long remote packet."));
 
   if (putpkt (rs->buf) < 0)