Page MenuHome

Fix T66631: Crash when converting objects from Curve to Mesh

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



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

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.

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.


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.


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…