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:
authorHans Goudey <h.goudey@me.com>2021-12-30 01:53:02 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2022-01-11 12:08:12 +0300
commit50c39ff8fe041153bda41657a694e0b154b8cd65 (patch)
treee52550f4e9ecd600ff3b33be986d6aec43b660a4
parent512014f04216de3d488a8b4732fb72d538e38858 (diff)
Fix T94454: Python API curve to mesh use after free without depsgraph
This was caused by a mistake in eb0eb54d9644c5139, which removed the clearing of the curve edit mode pointers that are set when creating the temporary data for the conversion. If they are not cleared, the generic ID free function will also free the edit mode data, which is wrong when the source curve is in edit mode.
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 1769be54211..b7a8704e1d4 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -901,6 +901,20 @@ static Object *object_for_curve_to_mesh_create(const Object *object)
return temp_object;
}
+static void object_for_curve_to_mesh_free(Object *temp_object)
+{
+ /* Clear edit mode pointers that were explicitly copied to the temporary curve. */
+ ID *final_object_data = static_cast<ID *>(temp_object->data);
+ if (GS(final_object_data->name) == ID_CU) {
+ Curve &curve = *reinterpret_cast<Curve *>(final_object_data);
+ curve.editfont = nullptr;
+ curve.editnurb = nullptr;
+ }
+
+ BKE_id_free(nullptr, temp_object->data);
+ BKE_id_free(nullptr, temp_object);
+}
+
/**
* Populate `object->runtime.curve_cache` which is then used to create the mesh.
*/
@@ -1003,8 +1017,7 @@ static Mesh *mesh_new_from_curve_type_object(const Object *object)
Mesh *mesh = mesh_new_from_evaluated_curve_type_object(temp_object);
- BKE_id_free(nullptr, temp_object->data);
- BKE_id_free(nullptr, temp_object);
+ object_for_curve_to_mesh_free(temp_object);
return mesh;
}