aboutsummaryrefslogtreecommitdiff
path: root/sim/common/sim-utils.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2015-11-21 23:10:04 -0800
committerMike Frysinger <vapier@gentoo.org>2015-11-22 02:15:28 -0500
commit2561d5808a330240a28841e8b3ce706a65ed31c9 (patch)
tree487875e6a4fa55deb3694d629983a9006d9f8a59 /sim/common/sim-utils.c
parent7c125e3b10ac6f9222d24c76cdf31a5a9ec8dae0 (diff)
downloadgdb-2561d5808a330240a28841e8b3ce706a65ed31c9.zip
gdb-2561d5808a330240a28841e8b3ce706a65ed31c9.tar.gz
gdb-2561d5808a330240a28841e8b3ce706a65ed31c9.tar.bz2
sim: sim_do_commandf: fix call to va_end [PR sim/19273]
Make sure we call va_end even in the error case.
Diffstat (limited to 'sim/common/sim-utils.c')
-rw-r--r--sim/common/sim-utils.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c
index 63d532d..c6f96a8 100644
--- a/sim/common/sim-utils.c
+++ b/sim/common/sim-utils.c
@@ -328,15 +328,20 @@ sim_do_commandf (SIM_DESC sd,
{
va_list ap;
char *buf;
+ int ret;
+
va_start (ap, fmt);
- if (vasprintf (&buf, fmt, ap) < 0)
+ ret = vasprintf (&buf, fmt, ap);
+ va_end (ap);
+
+ if (ret < 0)
{
sim_io_eprintf (sd, "%s: asprintf failed for `%s'\n",
STATE_MY_NAME (sd), fmt);
return;
}
+
sim_do_command (sd, buf);
- va_end (ap);
free (buf);
}