GNOME Bugzilla – Bug 737741
g_datalist_id_get_data assertion fails for non-existant keys
Last modified: 2014-10-02 18:44:23 UTC
Before glib 2.29.6, g_datalist_get_data was a macro of the form #define g_datalist_get_data(dl, k) \ (g_datalist_id_get_data ((dl), g_quark_try_string (k))) At which point it was converted into a regular function in 1cceda4 (released in 2.29.6). Whenever g_datalist_get_data was called with a non-existant key, g_quark_try_string would return 0 and the function would behave as expected. In 06e3a1d7 (released in 2.33.12) the code of g_datalist_id_get_data was changed to use a lockless mechanism, however a new assertion was added that key_id should be != 0. The function previously silently returned NULL when used with key_id == 0. The end result is that code compiled against glib < 2.29.6 but linked against glib > 2.33.12 will show an assertion fail whenever g_datalist_get_data is called with a string that doesn't have a quark.
I believe it would be appropriate to silently return NULL in g_datalist_id_get_data if key_id == 0.