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.

Signed-off-by: Yevhenii Kharchenko <>
Fixes piglit test: 'arb_copy_image add-illegal-levels'
53 jobs for !23 with fix/mesa_unexpected_texture_levels
merge request