diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2019-07-10 13:58:39 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2019-07-10 15:13:42 +0300 |
commit | b39d7e484c6be45fb8ffe0809aecb5726b7d1936 (patch) | |
tree | 468e0c92b102f06b3736ea0f85ba0395fbac9d29 /source/blender/blenkernel/intern | |
parent | d3e1782abc3be15fdc45e5139ebe1e9638d52734 (diff) |
Fix T66631: Crash when converting objects from Curve to Mesh
When `BKE_mesh_new_from_object()` cannot convert an object to a mesh, it
returns `NULL`. This case was not handled at all in
`BKE_mesh_new_from_object_to_bmain()` or `curvetomesh()`, causing a
segmentation fault.
This commit fixes the segmentation fault, and leaves the curve object as
a curve object.
Reviewed By: mont29, brecht, sergey
Differential Revision: https://developer.blender.org/D5217
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_convert.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index dd36da44b92..fec83ebc899 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -1048,6 +1048,7 @@ static Mesh *mesh_new_from_curve_type_object(Object *object) /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked. If it didn't the curve did * not have any segments or otherwise would have generated an empty mesh. */ if (temp_object->type != OB_MESH) { + BKE_id_free(NULL, temp_object->data); BKE_id_free(NULL, temp_object); return NULL; } @@ -1216,6 +1217,10 @@ Mesh *BKE_mesh_new_from_object_to_bmain(Main *bmain, bool preserve_all_data_layers) { Mesh *mesh = BKE_mesh_new_from_object(depsgraph, object, preserve_all_data_layers); + if (mesh == NULL) { + /* Unable to convert the object to a mesh. */ + return NULL; + } /* Make sure mesh only points original datablocks, also increase users of materials and other * possibly referenced data-blocks. |