[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] vbox: check getenv("DISPLAY") for NULL in vboxDomainDumpXML



On Thu, Jun 10, 2010 at 10:44:33PM +0200, Matthias Bolte wrote:
> Otherwise this will segfault if DISPLAY is not defined.
> ---
>  src/vbox/vbox_tmpl.c |   16 ++++++++++------
>  1 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
> index 1372f96..dfa76a6 100644
> --- a/src/vbox/vbox_tmpl.c
> +++ b/src/vbox/vbox_tmpl.c
> @@ -1915,6 +1915,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
>      vboxIID  *iid        = NULL;
>      int gotAllABoutDef   = -1;
>      nsresult rc;
> +    char *tmp;
>  
>  #if VBOX_API_VERSION == 2002
>      if (VIR_ALLOC(iid) < 0) {
> @@ -2191,12 +2192,15 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
>                  } else if ((vrdpPresent != 1) && (totalPresent == 0) && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
>                      if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
>                          def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
> -                        def->graphics[def->ngraphics]->data.desktop.display = strdup(getenv("DISPLAY"));
> -                        if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
> -                            virReportOOMError();
> -                            /* just don't go to cleanup yet as it is ok to have
> -                             * display as NULL
> -                             */
> +                        tmp = getenv("DISPLAY");
> +                        if (tmp != NULL) {
> +                            def->graphics[def->ngraphics]->data.desktop.display = strdup(tmp);
> +                            if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
> +                                virReportOOMError();
> +                                /* just don't go to cleanup yet as it is ok to have
> +                                 * display as NULL
> +                                 */
> +                            }
>                          }
>                          totalPresent++;
>                          def->ngraphics++;

ACK

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]