[Mesa-dev] [PATCH 3/6] meta: react to NULL pointers in create_texture_for_pbo()

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Mon Jan 26 01:07:48 PST 2015


Check if null pointers were given and bail out.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 src/mesa/drivers/common/meta_tex_subimage.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c
index 977ee5a..cd5218e 100644
--- a/src/mesa/drivers/common/meta_tex_subimage.c
+++ b/src/mesa/drivers/common/meta_tex_subimage.c
@@ -82,6 +82,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
       assert(create_pbo);
 
       _mesa_GenBuffers(1, tmp_pbo);
+      if (!tmp_pbo)
+         return NULL;
 
       /* We are not doing this inside meta_begin/end.  However, we know the
        * client doesn't have the given target bound, so we can go ahead and
@@ -98,6 +100,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,
    }
 
    _mesa_GenTextures(1, tmp_tex);
+   if (!tmp_tex) {
+      _mesa_DeleteBuffers(1, tmp_pbo);
+      return NULL;
+   }
+
    tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);
    tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
    tex_obj->Immutable = GL_TRUE;
-- 
1.8.5.1



More information about the mesa-dev mailing list