st/mesa: fix corrupted texture levels, when adding more levels than expected
authorYevhenii Kharchenko <evgen.kharchenko.ua@gmail.com>
Wed, 1 Jul 2020 14:36:18 +0000 (17:36 +0300)
committerMarge Bot <eric+marge@anholt.net>
Thu, 16 Jul 2020 10:26:30 +0000 (10:26 +0000)
commita0f84396913d478c926626593514de1ab6ebb439
treef32a4014ac8c82ba18d7efacd17f8a1645b8db46
parentb8c0196116d3ed68d111a4ede06b22ddf3d2c5c3
st/mesa: fix corrupted texture levels, when adding more levels than expected

Some of existing texture levels can be corruted,
after calling 'glTexImage' with param 'level' higher than
max expected value 'floor(log2(max(width, height, depth)))'.

To fix we prevent overwriting image buffer pointer
in 'st_texture_object', if it was already allocated
for multiple mip-levels storage.

Fixes piglit test: 'arb_copy_image add-illegal-levels'

Signed-off-by: Yevhenii Kharchenko <yevhenii.kharchenko@globallogic.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5785>
src/mesa/state_tracker/st_cb_texture.c