mirror of
https://github.com/brl/mutter.git
synced 2025-02-02 06:42:28 +00:00
object: avoid creating a new entry for NULL data
If setting NULL user data via cogl_object_set_user_data() and we fail to find an entry for the given key then bail out before potentially allocating a new entry since setting NULL data is documented to effectively delete an entry. Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
parent
31097c0488
commit
ed06d0ca01
@ -190,6 +190,12 @@ _cogl_object_set_user_data (CoglObject *object,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/* NB: Setting a value of NULL is documented to delete the
|
||||||
|
* corresponding entry so we can return immediately in this
|
||||||
|
* case. */
|
||||||
|
if (user_data == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (G_LIKELY (object->n_user_data_entries <
|
if (G_LIKELY (object->n_user_data_entries <
|
||||||
COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES))
|
COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES))
|
||||||
entry = &object->user_data_entry[object->n_user_data_entries++];
|
entry = &object->user_data_entry[object->n_user_data_entries++];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user