]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix crash in virsh after bogus command
authorChris Lalancette <clalance@redhat.com>
Fri, 12 Mar 2010 11:00:46 +0000 (12:00 +0100)
committerDaniel Veillard <veillard@redhat.com>
Fri, 12 Mar 2010 11:00:46 +0000 (12:00 +0100)
If you ran virsh in interactive mode and ran a command
that virsh could not parse, it would then SEGV
on subsequent commands.  The problem is that we are
freeing the vshCmd structure in the syntaxError label
at the end of vshCommandParse, but forgetting to
set ctl->cmd to NULL.  This means that on the next command,
we would try to free the same structure again, leading
to badness.

* tools/virsh.c: Make sure to set ctl->cmd to NULL after
  freeing it in vshCommandParse()

tools/virsh.c

index 952114470e92604c7df541e85a94155b91f8256e..aa85ee65e4f81085669520caac871af3223943f4 100644 (file)
@@ -8639,8 +8639,10 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
     return TRUE;
 
  syntaxError:
-    if (ctl->cmd)
+    if (ctl->cmd) {
         vshCommandFree(ctl->cmd);
+        ctl->cmd = NULL;
+    }
     if (first)
         vshCommandOptFree(first);
     VIR_FREE(tkdata);