forked from Imagelibrary/binutils-gdb
sim: sim_do_commandf: fix call to va_end [PR sim/19273]
Make sure we call va_end even in the error case.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user