Add an assert to BKE_icon_changed() that we are actually dealing with ID icon.
authorBastien Montagne <montagne29@wanadoo.fr>
Fri, 16 Mar 2018 16:17:19 +0000 (17:17 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Fri, 16 Mar 2018 16:17:19 +0000 (17:17 +0100)
Otherwise, ID->obj is an opaque pointer, wrong usage here could lead to
a vast amount of bad things.

source/blender/blenkernel/intern/icons.c

index d56d758..7302d62 100644 (file)
@@ -440,6 +440,9 @@ void BKE_icon_changed(const int icon_id)
        icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id));
        
        if (icon) {
+               /* We *only* expect ID-tied icons here, not non-ID icon/preview! */
+               BLI_assert(icon->type != 0);
+
                /* Do not enforce creation of previews for valid ID types using BKE_previewimg_id_ensure() here ,
                 * we only want to ensure *existing* preview images are properly tagged as changed/invalid, that's all. */
                PreviewImage **p_prv = BKE_previewimg_id_get_p((ID *)icon->obj);