Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2019-07-10 13:58:39 +0300
committerSybren A. Stüvel <sybren@blender.org>2019-07-10 15:13:42 +0300
commitb39d7e484c6be45fb8ffe0809aecb5726b7d1936 (patch)
tree468e0c92b102f06b3736ea0f85ba0395fbac9d29 /source/blender/blenkernel/intern/mesh_convert.c
parentd3e1782abc3be15fdc45e5139ebe1e9638d52734 (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/mesh_convert.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.c5
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.