meta: Fix error paths in meta_copy_image.c
authorJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Mon, 8 Sep 2014 10:59:50 +0000 (13:59 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Tue, 23 Sep 2014 07:25:02 +0000 (10:25 +0300)
If _mesa_get_tex_image() return NULL there is already error
set in context. Other error pats free allocated texture.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/mesa/drivers/common/meta_copy_image.c

index 0c204b87d656eab362dab1dfaf3df8c6150c59bc..fc0cbaf1bd8fad6be397106601fc76225961b2d9 100644 (file)
@@ -63,12 +63,21 @@ make_view(struct gl_context *ctx, struct gl_texture_image *tex_image,
    if (!ctx->Driver.TestProxyTexImage(ctx, tex_obj->Target, 0, tex_format,
                                       tex_image->Width, tex_image->Height,
                                       tex_image->Depth, 0)) {
+      _mesa_DeleteTextures(1, view_tex_name);
+      *view_tex_name = 0;
       return false;
    }
 
    view_tex_obj->Target = tex_obj->Target;
 
    *view_tex_image = _mesa_get_tex_image(ctx, view_tex_obj, tex_obj->Target, 0);
+
+   if (!*view_tex_image) {
+      _mesa_DeleteTextures(1, view_tex_name);
+      *view_tex_name = 0;
+      return false;
+   }
+
    _mesa_init_teximage_fields(ctx, *view_tex_image,
                               tex_image->Width, tex_image->Height,
                               tex_image->Depth,