
Thanks and push now. -- Regards, Alex ----- Original Message ----- From: "Eric Blake" <eblake@redhat.com> To: "Alex Jia" <ajia@redhat.com> Cc: libvir-list@redhat.com Sent: Friday, September 14, 2012 12:38:39 AM Subject: Re: [libvirt] [PATCH] conf: avoid libvirt crash with empty address guestfwd channel On 09/13/2012 10:23 AM, Alex Jia wrote:
The 'def->target.addr' hasn't been initialized in virDomainChrDefNew() and its value is always '0xffffffff', in addition, the following test scenario hasn't also include 'port' element in channel XML block, so the branch 'if (addrStr == NULL)' is hit in virDomainChrDefParseTargetXML(), the programming jumps to 'error' label to release relevant resources, and the statement 'if (VIR_ALLOC(def->target.addr) < 0)' hasn't been executed then the virDomainChrDefFree() will free 'def->target.addr'(0xffffffff) via VIR_FREE(), which results in libvirt crash, to use valgrind can also find a 'Invalid free() / delete / delete[]' error. This patch just adjusts codes order to initialize 'def->target.addr' firstly.
With this patch, libvirt hasn't crash and can get a expected error message " XML error: guestfwd channel does not define a target address".
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org