st/mesa: fix pipe resource leak
authorJuan A. Suarez Romero <jasuarez@igalia.com>
Fri, 30 Apr 2021 10:58:22 +0000 (12:58 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 11 May 2021 07:46:17 +0000 (07:46 +0000)
When switching from a normal texture to a texture storage, unreference
the old one to avoid leaking it.

v2 (Emma):
 - Update commit message

Reviewed-by: Emma Anholt <emma@anholt.net>
Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10643>

src/mesa/state_tracker/st_cb_texture.c

index d220f1e..3a4762d 100644 (file)
@@ -3054,6 +3054,8 @@ st_texture_storage(struct gl_context *ctx,
                                    width, height, depth,
                                    &ptWidth, &ptHeight, &ptDepth, &ptLayers);
 
+   pipe_resource_reference(&stObj->pt, NULL);
+
    if (smObj) {
       stObj->pt = st_texture_create_from_memory(st,
                                                 smObj,