]> git.sesse.net Git - mlt/commitdiff
fix invalid free when making absolute path relative
authorDan Dennedy <dan@dennedy.org>
Sat, 28 Jan 2012 19:31:42 +0000 (11:31 -0800)
committerDan Dennedy <dan@dennedy.org>
Sat, 28 Jan 2012 19:31:42 +0000 (11:31 -0800)
Patch by j-b-m and reformatted by me.

src/modules/xml/consumer_xml.c

index 66c10f30e6d19336024dda76c4ccb5fc589b4dcb..3e1544b54e60a2ad2f0bcd414bbb879a234959f6 100644 (file)
@@ -60,7 +60,7 @@ static int consumer_is_stopped( mlt_consumer this );
 static void *consumer_thread( void *arg );
 static void serialise_service( serialise_context context, mlt_service service, xmlNode *node );
 
-static void* filter_restricted( const char *in )
+static char* filter_restricted( const char *in )
 {
        if ( !in ) return NULL;
        size_t n = strlen( in );
@@ -235,9 +235,11 @@ static void serialise_properties( serialise_context context, mlt_properties prop
                        if ( value )
                        {
                                int rootlen = strlen( context->root );
+                               // convert absolute path to relative
                                if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
-                                       value += rootlen + 1;
-                               p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
+                                       p = xmlNewTextChild( node, NULL, _x("property"), _x(value + rootlen + 1 ) );
+                               else
+                                       p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
                                xmlNewProp( p, _x("name"), _x(name) );
                                free( value );
                        }
@@ -260,9 +262,11 @@ static void serialise_store_properties( serialise_context context, mlt_propertie
                        if ( value )
                        {
                                int rootlen = strlen( context->root );
+                               // convert absolute path to relative
                                if ( rootlen && !strncmp( value, context->root, rootlen ) && value[ rootlen ] == '/' )
-                                       value += rootlen + 1;
-                               p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
+                                       p = xmlNewTextChild( node, NULL, _x("property"), _x(value + rootlen + 1) );
+                               else
+                                       p = xmlNewTextChild( node, NULL, _x("property"), _x(value) );
                                xmlNewProp( p, _x("name"), _x(name) );
                                free( value );
                        }