st/dri: NULL check before deref DRI loader .getCapability
authorEmil Velikov <emil.velikov@collabora.com>
Mon, 31 Jul 2017 18:46:22 +0000 (19:46 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 2 Aug 2017 19:42:19 +0000 (20:42 +0100)
One could have vX+1 which introduces another entrypoint without
implementing older ones.

v2: Rebase, while keeping loaderPrivate

Fixes: 1bf703e4ea5 ("dri_interface,egl,gallium: only expose RGBA visuals
on Android")
Cc: 17.2 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/state_trackers/dri/dri_screen.c

index f888abd6e7047c675368f43bfed5e8cdfc9a6b06..b992d24068b73a3f403a6f0f1c26791daf21656e 100644 (file)
@@ -93,10 +93,12 @@ dri_loader_get_cap(struct dri_screen *screen, enum dri_loader_cap cap)
    const __DRIdri2LoaderExtension *dri2_loader = screen->sPriv->dri2.loader;
    const __DRIimageLoaderExtension *image_loader = screen->sPriv->image.loader;
 
-   if (dri2_loader && dri2_loader->base.version >= 4)
+   if (dri2_loader && dri2_loader->base.version >= 4 &&
+       dri2_loader->getCapability)
       return dri2_loader->getCapability(screen->sPriv->loaderPrivate, cap);
 
-   if (image_loader && image_loader->base.version >= 2)
+   if (image_loader && image_loader->base.version >= 2 &&
+       image_loader->getCapability)
       return image_loader->getCapability(screen->sPriv->loaderPrivate, cap);
 
    return 0;