Module: Mesa Branch: staging/23.2 Commit: 7599d6e5b575a52219a970894ef243558b7dda92 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7599d6e5b575a52219a970894ef243558b7dda92
Author: Gert Wollny <[email protected]> Date: Mon Oct 2 15:38:19 2023 +0200 copyimage: check requested slice early when cube maps are involved The generalized check for the z-slice happens in 'check_region_bounds', but this function requires the image pointer that is acquired in `prepare_target_err`, therefore replace the assertion with a proper test. v2: Also check for negative value (Brian Paul) CC: mesa-stable Signed-off-by: Gert Wollny <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25507> (cherry picked from commit 16662f8d3a57458325bd5381910722f67699fea6) --- .pick_status.json | 2 +- src/mesa/main/copyimage.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a2491880aef..47ce4d9fe28 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1594,7 +1594,7 @@ "description": "copyimage: check requested slice early when cube maps are involved", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/mesa/main/copyimage.c b/src/mesa/main/copyimage.c index 3d0d8af6946..3fcfd3dda15 100644 --- a/src/mesa/main/copyimage.c +++ b/src/mesa/main/copyimage.c @@ -239,7 +239,11 @@ prepare_target_err(struct gl_context *ctx, GLuint name, GLenum target, if (target == GL_TEXTURE_CUBE_MAP) { int i; - assert(z < MAX_FACES); /* should have been caught earlier */ + if (z < 0 || z >= MAX_FACES) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glCopyImageSubData(cube face (%sZ = %d)", dbg_prefix, z); + return false; + } /* make sure all the cube faces are present */ for (i = 0; i < depth; i++) {
