Page MenuHome

Fix T66631: Crash when converting objects from Curve to Mesh
ClosedPublic

Authored by Sybren A. Stüvel (sybren) on Jul 10 2019, 1:01 PM.

Details

Summary

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.

Fixes T66631

Diff Detail

Repository
rB Blender

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Jul 10 2019, 1:39 PM
Brecht Van Lommel (brecht) added inline comments.
source/blender/editors/object/object_add.c
2356

I don't think it's correct to just continue here. At this point the new object is already created and it's not clear that the remaining code below (test_object_materials etc) can be skipped.

Safest is to just do nothing here if this fails I think, but add a comment that no assumption should be made that the resulting objects is a mesh.

Later this could be refactored to do the conversion before creating the object, or to make it so conversion can't fail and e.g. creates an empty mesh.

2380

Same comment here.

This revision now requires changes to proceed.Jul 10 2019, 1:39 PM
  • Handled feedback from Brecht + addressed another memory leak
Sybren A. Stüvel (sybren) marked 2 inline comments as done.Jul 10 2019, 1:52 PM
This revision is now accepted and ready to land.Jul 10 2019, 2:02 PM

Interesting that single-point curve can't be converted to a single-vertex mesh. But that's another story.

The patch looks good to me.

source/blender/editors/object/object_add.c
2035–2046

Not sure you need that change anymore then? If we try to keep this as minimal as possible for 2.80… just early return in case mesh is NULL?

Sybren A. Stüvel (sybren) marked an inline comment as done.Jul 10 2019, 2:10 PM

Ah, forgot the 'accept' green light ;)

Imho, on a longer term, we should ensure obdata conversion logic always return a valid datablock (mesh in that case), be it empty, yes…