evas: Fix potential crash with draw context

Using filters I end up in situations where this function returns NULL
and all hell breaks loose. I guess the spinlock is what makes this
possible (race condition).

@fix
This commit is contained in:
Jean-Philippe Andre 2017-12-13 19:16:28 +09:00
parent fcdf4e9d10
commit fc82281603
1 changed files with 4 additions and 6 deletions

View File

@ -107,13 +107,9 @@ _evas_common_draw_context_stash(RGBA_Draw_Context *dc)
static RGBA_Draw_Context *
_evas_common_draw_context_find(void)
{
RGBA_Draw_Context *dc;
RGBA_Draw_Context *dc = NULL;
if (!_ctxt_spares)
{
dc = malloc(sizeof(RGBA_Draw_Context));
}
else
if (_ctxt_spares)
{
SLKL(_ctx_spares_lock);
dc = eina_trash_pop(&_ctxt_spares);
@ -121,6 +117,8 @@ _evas_common_draw_context_find(void)
SLKU(_ctx_spares_lock);
}
if (!dc) dc = malloc(sizeof(RGBA_Draw_Context));
return dc;
}