Fix material null pointer reference in buttons_context.c

ASAN reported null pointer access when converting a mesh to curves.
Check if the material is a null pointer before trying to use it.
This commit is contained in:
Sebastian Parborg 2020-09-09 16:03:19 +02:00
parent 5c0eda51ff
commit 8bead3df2f
1 changed files with 3 additions and 0 deletions

View File

@ -333,6 +333,9 @@ static bool buttons_context_path_material(ButsContextPath *path)
if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
ma = BKE_object_material_get(ob, ob->actcol);
if (ma == NULL) {
return false;
}
RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
path->len++;
return true;