mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
offscreen: Plug a leak in an error path
When creating a CoglOffscreen we take a reference on the texture handle, but in case of error we never release it. We should take that reference only on success. http://bugzilla.clutter-project.org/show_bug.cgi?id=2620
This commit is contained in:
parent
28c0a4d6be
commit
02d14ec15c
@ -862,7 +862,7 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
_cogl_texture_set_filters (texhandle, GL_NEAREST, GL_NEAREST);
|
_cogl_texture_set_filters (texhandle, GL_NEAREST, GL_NEAREST);
|
||||||
|
|
||||||
offscreen = g_new0 (CoglOffscreen, 1);
|
offscreen = g_new0 (CoglOffscreen, 1);
|
||||||
offscreen->texture = cogl_handle_ref (texhandle);
|
offscreen->texture = texhandle;
|
||||||
|
|
||||||
if ((create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
|
if ((create_flags & COGL_OFFSCREEN_DISABLE_DEPTH_AND_STENCIL))
|
||||||
fbo_created = try_creating_fbo (offscreen, 0, &data);
|
fbo_created = try_creating_fbo (offscreen, 0, &data);
|
||||||
@ -898,8 +898,12 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
data.level_width,
|
data.level_width,
|
||||||
data.level_height);
|
data.level_height);
|
||||||
|
|
||||||
|
/* take a reference on the texture */
|
||||||
|
cogl_handle_ref (offscreen->texture);
|
||||||
|
|
||||||
ret = _cogl_offscreen_object_new (offscreen);
|
ret = _cogl_offscreen_object_new (offscreen);
|
||||||
_cogl_texture_associate_framebuffer (texhandle, COGL_FRAMEBUFFER (ret));
|
_cogl_texture_associate_framebuffer (texhandle, COGL_FRAMEBUFFER (ret));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -907,6 +911,7 @@ _cogl_offscreen_new_to_texture_full (CoglHandle texhandle,
|
|||||||
g_free (offscreen);
|
g_free (offscreen);
|
||||||
/* XXX: This API should probably have been defined to take a GError */
|
/* XXX: This API should probably have been defined to take a GError */
|
||||||
g_warning ("%s: Failed to create an OpenGL framebuffer", G_STRLOC);
|
g_warning ("%s: Failed to create an OpenGL framebuffer", G_STRLOC);
|
||||||
|
|
||||||
return COGL_INVALID_HANDLE;
|
return COGL_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user