Check for empty property name in GPropertyAction

Make sure to fail consistently in case people created a GPropertyAction
with g_object_new() without passing a property name.

Bindings that construct objects with g_object_new() have no idea if a
property is mandatory.

See: #3130
This commit is contained in:
Emmanuele Bassi 2023-09-30 17:58:49 +01:00 committed by Philip Withnall
parent 525508be0d
commit 3a2af81ced

View File

@ -313,6 +313,15 @@ g_property_action_set_property_name (GPropertyAction *paction,
GParamSpec *pspec;
gchar *detailed;
/* In case somebody is constructing GPropertyAction without passing
* a property name
*/
if (G_UNLIKELY (property_name == NULL || property_name[0] == '\0'))
{
g_critical ("Attempted to use an empty property name for GPropertyAction");
return;
}
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (paction->object), property_name);
if (pspec == NULL)