st/mesa: fix memleak in glDrawPixels cache code
authorBrian Paul <brianp@vmware.com>
Tue, 12 Apr 2016 00:54:28 +0000 (18:54 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 12 Apr 2016 16:44:45 +0000 (10:44 -0600)
commit6c014782138634d5d36e1484bf498cef2b2d888f
tree39862aa94398844dc5404af79572af61a8de9350
parentb5105e67a860c6c3271ad7d48e2d80e84c3e8ade
st/mesa: fix memleak in glDrawPixels cache code

If the glDrawPixels size changed, we leaked the previously cached
texture, if there was one.  This patch fixes the reference counting,
adds a refcount assertion check, and better handles potential malloc()
failures.

Tested with a modified version of the drawpix Mesa demo which changed
the image size for each glDrawPixels call.

Cc: "11.2" <mesa-stable@lists.freedesktop.org>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/mesa/state_tracker/st_cb_drawpixels.c