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

Re: [libvirt] [PATCH] tests: fix test segfault when libxl configuration setup fails.



On Thu, Aug 02, 2018 at 01:06:39AM -0300, Julio Faracco wrote:
> This commit fixes a segmentation fault caused by missing conditional to
> check if libxl configuration was properly created by the test. If the
> configuration was not properly created, libxlDriverConfigNew() function
> will return NULL and cause a segfault at cfg->caps = NULL during the
> cleanup.
>
> Signed-off-by: Julio Faracco <jcfaracco gmail com>
> ---
>  tests/libxlxml2domconfigtest.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tests/libxlxml2domconfigtest.c b/tests/libxlxml2domconfigtest.c
> index 34a63e22b5..a9758c40cb 100644
> --- a/tests/libxlxml2domconfigtest.c
> +++ b/tests/libxlxml2domconfigtest.c
> @@ -138,7 +138,8 @@ testCompareXMLToDomConfig(const char *xmlfile,
>      libxl_domain_config_dispose(&actualconfig);
>      libxl_domain_config_dispose(&expectconfig);
>      xtl_logger_destroy(log);
> -    cfg->caps = NULL;
> +    if (cfg)
> +        cfg->caps = NULL;
>      virObjectUnref(cfg);
>      return ret;

Either this or move the "if (!(cfg - libxlDriverConfigNew()))" before the calls
to the libxl library and return a failure right away, but I don't have a strong
preference here, so

Reviewed-by: Erik Skultety <eskultet redhat com>


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