st/nine: Fix crash on texture creation failure
authorAxel Davy <davyaxel0@gmail.com>
Fri, 12 Mar 2021 12:16:13 +0000 (13:16 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 14 Apr 2021 08:33:13 +0000 (08:33 +0000)
Fixes regression introduced by:
a179ea2e "st/nine: Use the texture memory helper"

The device is used on texture/surface dtor since this commit.
We need to early fill the device field in case of error.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
Acked-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10160>

src/gallium/frontends/nine/cubetexture9.c
src/gallium/frontends/nine/surface9.c
src/gallium/frontends/nine/texture9.c

index 052845b..0e87acd 100644 (file)
@@ -54,6 +54,8 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
         This, pParams, EdgeLength, Levels, Usage,
         Format, Pool, pSharedHandle);
 
+    This->base.base.base.device = pParams->device; /* Early fill this field in case of failure */
+
     user_assert(EdgeLength, D3DERR_INVALIDCALL);
 
     /* user_assert(!pSharedHandle || Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL); */
index e8479b8..e040aed 100644 (file)
@@ -68,6 +68,7 @@ NineSurface9_ctor( struct NineSurface9 *This,
 
     /* Mark this as a special surface held by another internal resource. */
     pParams->container = pContainer;
+    This->base.base.device = pParams->device; /* Early fill this field in case of failure */
     /* Make sure there's a Desc */
     assert(pDesc);
 
index 3163b85..af0054a 100644 (file)
@@ -56,6 +56,8 @@ NineTexture9_ctor( struct NineTexture9 *This,
     HRESULT hr;
     struct nine_allocation *user_buffer = NULL, *user_buffer_for_level;
 
+    This->base.base.base.device = pParams->device; /* Early fill this field in case of failure */
+
     DBG("(%p) Width=%u Height=%u Levels=%u Usage=%s Format=%s Pool=%s "
         "pSharedHandle=%p\n", This, Width, Height, Levels,
         nine_D3DUSAGE_to_str(Usage),