Make sure we call va_end even in the error case.
+2015-11-21 Mike Frysinger <vapier@gentoo.org>
+
+ PR sim/19273
+ * sim-utils.c (sim_do_commandf): Declare ret. Call va_start,
+ vasprintf, and va_end together. Check ret after va_end call.
+
2015-11-21 Mike Frysinger <vapier@gentoo.org>
* sim-types.h (SIM_PRI_TB): Define.
{
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);
}