Skip to content

Commit 56b2e3e

Browse files
committed
Do not return a data pointer when the property is a rect
The properties in metadata assumes that a data pointer is a nested property structure. But a rect type was returning a data pointer - causing a crash.
1 parent 390212f commit 56b2e3e

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

src/framework/mlt_property.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mlt_property mlt_property_init()
120120
static void clear_property(mlt_property self)
121121
{
122122
// Special case data handling
123-
if (self->types & mlt_prop_data && self->destructor != NULL)
123+
if (self->data && self->destructor)
124124
self->destructor(self->data);
125125

126126
// Special case string handling
@@ -753,6 +753,9 @@ char *mlt_property_get_string_tf(mlt_property self, mlt_time_format time_format)
753753
} else if (self->types & mlt_prop_data && self->data && self->serialiser) {
754754
self->types |= mlt_prop_string;
755755
self->prop_string = self->serialiser(self->data, self->length);
756+
} else if (self->types & mlt_prop_rect && self->data && self->serialiser) {
757+
self->types |= mlt_prop_string;
758+
self->prop_string = self->serialiser(self->data, self->length);
756759
}
757760
}
758761
pthread_mutex_unlock(&self->mutex);
@@ -852,6 +855,9 @@ char *mlt_property_get_string_l_tf(mlt_property self,
852855
} else if (self->types & mlt_prop_data && self->data && self->serialiser) {
853856
self->types |= mlt_prop_string;
854857
self->prop_string = self->serialiser(self->data, self->length);
858+
} else if (self->types & mlt_prop_rect && self->data && self->serialiser) {
859+
self->types |= mlt_prop_string;
860+
self->prop_string = self->serialiser(self->data, self->length);
855861
}
856862
#if !defined(_WIN32)
857863
// Restore the current locale
@@ -904,7 +910,9 @@ void *mlt_property_get_data(mlt_property self, int *length)
904910

905911
// Return the data (note: there is no conversion here)
906912
pthread_mutex_lock(&self->mutex);
907-
void *result = self->data;
913+
void *result = NULL;
914+
if (self->types & mlt_prop_data)
915+
result = self->data;
908916
pthread_mutex_unlock(&self->mutex);
909917
return result;
910918
}
@@ -951,7 +959,7 @@ void mlt_property_pass(mlt_property self, mlt_property that)
951959
self->prop_string = strdup(that->prop_string);
952960
} else if (that->types & mlt_prop_rect) {
953961
clear_property(self);
954-
self->types = mlt_prop_rect | mlt_prop_data;
962+
self->types = mlt_prop_rect;
955963
self->length = that->length;
956964
self->data = calloc(1, self->length);
957965
memcpy(self->data, that->data, self->length);
@@ -1889,7 +1897,7 @@ int mlt_property_set_rect(mlt_property self, mlt_rect value)
18891897
{
18901898
pthread_mutex_lock(&self->mutex);
18911899
clear_property(self);
1892-
self->types = mlt_prop_rect | mlt_prop_data;
1900+
self->types = mlt_prop_rect;
18931901
self->length = sizeof(value);
18941902
self->data = calloc(1, self->length);
18951903
memcpy(self->data, &value, self->length);

src/tests/test_properties/test_properties.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,18 @@ private Q_SLOTS:
12261226
QCOMPARE(p.anim_get_rect("key", 25).y, 1.0);
12271227
}
12281228

1229+
void RectIsNotData()
1230+
{
1231+
Properties p;
1232+
mlt_rect r = {1, 2, 3, 4, 5};
1233+
p.set("a", r);
1234+
QCOMPARE(p.get_data("a"), (void *) 0);
1235+
1236+
p.set("b", "1.1/2.2:3.3x4.4:5.5");
1237+
r = p.get_rect("b");
1238+
QCOMPARE(p.get_data("b"), (void *) 0);
1239+
}
1240+
12291241
void ColorFromInt()
12301242
{
12311243
Properties p;

0 commit comments

Comments
 (0)