main: Refactor in teximage.c to handle NULL from _mesa_get_current_tex_object.
authorLaura Ekstrand <laura@jlekstrand.net>
Tue, 9 Dec 2014 21:40:45 +0000 (13:40 -0800)
committerLaura Ekstrand <laura@jlekstrand.net>
Thu, 8 Jan 2015 19:37:30 +0000 (11:37 -0800)
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/main/teximage.c

index 2f2f072c8e1409eaa031b63497adc686e4294ef5..d95967cc28e878f41c61d8f3555e5a38d2c5ad4c 100644 (file)
@@ -1871,6 +1871,9 @@ static GLboolean
 mutable_tex_object(struct gl_context *ctx, GLenum target)
 {
    struct gl_texture_object *texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return GL_FALSE;
+
    return !texObj->Immutable;
 }
 
@@ -3373,6 +3376,9 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image)
       _mesa_update_state(ctx);
 
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
+
    _mesa_lock_texture(ctx, texObj);
 
    if (texObj->Immutable) {
@@ -3469,7 +3475,11 @@ texsubimage(struct gl_context *ctx, GLuint dims, GLenum target, GLint level,
 {
    struct gl_texture_object *texObj;
    struct gl_texture_image *texImage;
+
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
+
    if (texsubimage_error_check(ctx, dims, texObj, target, level,
                                xoffset, yoffset, zoffset,
                                width, height, depth, format, type, false)) {
@@ -5276,7 +5286,10 @@ _mesa_TexImage2DMultisample(GLenum target, GLsizei samples,
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
+
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
 
    _mesa_texture_image_multisample(ctx, 2, texObj, target, samples,
                                    internalformat, width, height, 1,
@@ -5293,7 +5306,10 @@ _mesa_TexImage3DMultisample(GLenum target, GLsizei samples,
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
+
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
 
    _mesa_texture_image_multisample(ctx, 3, texObj, target, samples,
                                    internalformat, width, height, depth,
@@ -5309,7 +5325,10 @@ _mesa_TexStorage2DMultisample(GLenum target, GLsizei samples,
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
+
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
 
    _mesa_texture_image_multisample(ctx, 2, texObj, target, samples,
                                    internalformat, width, height, 1,
@@ -5325,7 +5344,10 @@ _mesa_TexStorage3DMultisample(GLenum target, GLsizei samples,
 {
    struct gl_texture_object *texObj;
    GET_CURRENT_CONTEXT(ctx);
+
    texObj = _mesa_get_current_tex_object(ctx, target);
+   if (!texObj)
+      return;
 
    _mesa_texture_image_multisample(ctx, 3, texObj, target, samples,
                                    internalformat, width, height, depth,