From 6114856f4096a33d31245c7cd27ecaff3595b9a7 Mon Sep 17 00:00:00 2001 From: Spencer Magnusson Date: Mon, 17 Jun 2024 16:14:02 -0700 Subject: [PATCH] #1680 fix segmentation fault when appending None Signed-off-by: Spencer Magnusson --- .../opentimelineio-bindings/otio_serializableObjects.cpp | 4 ++-- tests/test_track.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp index 290a70dae1..5a99ed8b8a 100644 --- a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp +++ b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp @@ -526,9 +526,9 @@ Should be subclassed (for example by :class:`.Track` and :class:`.Stack`), not u index = adjusted_vector_index(index, c->children()); c->remove_child(index, ErrorStatusHandler()); }, "index"_a) - .def("__internal_insert", [](Composition* c, int index, Composable* composable) { + .def("__internal_insert", [](Composition* c, int index, Composable &composable) { index = adjusted_vector_index(index, c->children()); - c->insert_child(index, composable, ErrorStatusHandler()); + c->insert_child(index, &composable, ErrorStatusHandler()); }, "index"_a, "item"_a) .def("__contains__", &Composition::has_child, "composable"_a) .def("__len__", [](Composition* c) { diff --git a/tests/test_track.py b/tests/test_track.py index fb2caccc7c..fbf09d3c3e 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -10,6 +10,10 @@ class TrackTests(unittest.TestCase, otio_test_utils.OTIOAssertions): + def test_append_none(self): + tr = otio.schema.Track() + self.assertRaises(TypeError, lambda x: tr.append(None)) + def test_find_children(self): cl = otio.schema.Clip() tr = otio.schema.Track()