Mesa (master): main/texobj: Check that texture id > 0 before looking it up in hash-table

Eduardo Lima Mitev elima at kemper.freedesktop.org
Thu Nov 24 07:25:35 UTC 2016


Module: Mesa
Branch: master
Commit: 89cbe0d21f8ed47f992b04b4a5595c4801d2b397
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=89cbe0d21f8ed47f992b04b4a5595c4801d2b397

Author: Eduardo Lima Mitev <elima at igalia.com>
Date:   Wed Nov 23 14:44:05 2016 +0100

main/texobj: Check that texture id > 0 before looking it up in hash-table

_mesa_lookup_texture_err() is not currently checking that the
texture-id can be zero, but _mesa_HashLookup() doesn't expect the key
to be zero, and will fail an assertion.

Considering that _mesa_lookup_texture_err() is called from
_mesa_GetTextureImage and _mesa_GetTextureSubImage with user provided
arguments, we must validate the texture-id before looking it up in the
hash-table.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/mesa/main/texobj.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index fbd498d..e5b7070 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -116,9 +116,10 @@ _mesa_lookup_texture(struct gl_context *ctx, GLuint id)
 struct gl_texture_object *
 _mesa_lookup_texture_err(struct gl_context *ctx, GLuint id, const char* func)
 {
-   struct gl_texture_object *texObj;
+   struct gl_texture_object *texObj = NULL;
 
-   texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not found. */
+   if (id > 0)
+      texObj = _mesa_lookup_texture(ctx, id); /* Returns NULL if not found. */
 
    if (!texObj)
       _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture)", func);




More information about the mesa-commit mailing list