vsh: cmdEcho: use separate variable for argument

Do not use 'arg' which is later used for an allocated string.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Ján Tomko 2021-08-10 17:10:34 +02:00
parent 2cbc686d66
commit f78e2495e5

View File

@ -3199,17 +3199,16 @@ cmdEcho(vshControl *ctl, const vshCmd *cmd)
while ((opt = vshCommandOptArgv(ctl, cmd, opt))) {
char *str;
g_auto(virBuffer) xmlbuf = VIR_BUFFER_INITIALIZER;
arg = opt->data;
const char *curr = opt->data;
if (count)
virBufferAddChar(&buf, ' ');
if (xml) {
virBufferEscapeString(&xmlbuf, "%s", arg);
virBufferEscapeString(&xmlbuf, "%s", curr);
str = virBufferContentAndReset(&xmlbuf);
} else {
str = g_strdup(arg);
str = g_strdup(curr);
}
if (shell)