st/mesa: fix sampler view leak in st_DrawAtlasBitmaps()
authorBrian Paul <brianp@vmware.com>
Thu, 14 Apr 2016 21:07:53 +0000 (15:07 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 14 Apr 2016 21:32:18 +0000 (15:32 -0600)
I neglected to free the sampler view which was created earlier in the
function.  So for each glCallLists() command that used the bitmap atlas
to draw text, we'd leak a sampler view object.

Also, check for st_create_texture_sampler_view() failure and record
GL_OUT_OF_MEMORY.

Cc: "11.1 11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/mesa/state_tracker/st_cb_bitmap.c

index 4fd2dfef8cc3c73c56e3e0cd50bf807d00be639a..b4d04b4de5fcc17d3e0a539049b4dd9d3a4d0950 100644 (file)
@@ -704,6 +704,10 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
    st_validate_state(st, ST_PIPELINE_RENDER);
 
    sv = st_create_texture_sampler_view(pipe, stObj->pt);
+   if (!sv) {
+      _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCallLists(bitmap text)");
+      return;
+   }
 
    setup_render_state(ctx, sv, color, true);
 
@@ -793,6 +797,8 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
 
    pipe_resource_reference(&vb.buffer, NULL);
 
+   pipe_sampler_view_reference(&sv, NULL);
+
    /* We uploaded modified constants, need to invalidate them. */
    st->dirty.mesa |= _NEW_PROGRAM_CONSTANTS;
 }