]> git.sesse.net Git - mlt/commitdiff
partially fix leak of service allocated in on_start_xxx
authorMaksym Veremeyenko <verem@m1stereo.tv>
Tue, 6 Nov 2012 15:20:53 +0000 (17:20 +0200)
committerDan Dennedy <dan@dennedy.org>
Sat, 10 Nov 2012 17:30:50 +0000 (09:30 -0800)
src/modules/xml/producer_xml.c

index 19160a267b73fefd600ee0f6066f2dd84c1ebe77..d38724e91af57f0fa7da929c8d99b903d243e0a7 100644 (file)
@@ -582,6 +582,7 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
                if ( !producer )
                {
                        mlt_service_close( service );
+                       free( service );
                        return;
                }
 
@@ -668,8 +669,12 @@ static void on_end_producer( deserialise_context context, const xmlChar *name )
                        // Push the producer onto the stack
                        context_push_service( context, producer, mlt_producer_type );
                }
+       }
 
+       if ( service )
+       {
                mlt_service_close( service );
+               free( service );
        }
 }
 
@@ -863,13 +868,17 @@ static void on_end_track( deserialise_context context, const xmlChar *name )
 
                if ( parent != NULL )
                        context_push_service( context, parent, parent_type );
-
-               mlt_service_close( track );
        }
        else
        {
                mlt_log_error( NULL, "[producer_xml] Invalid state at end of track\n" );
        }
+
+       if ( track )
+       {
+               mlt_service_close( track );
+               free( track );
+       }
 }
 
 static void on_start_filter( deserialise_context context, const xmlChar *name, const xmlChar **atts)
@@ -908,6 +917,7 @@ static void on_end_filter( deserialise_context context, const xmlChar *name )
                        if ( parent )
                                context_push_service( context, parent, parent_type );
                        mlt_service_close( service );
+                       free( service );
                        return;
                }
 
@@ -948,14 +958,17 @@ static void on_end_filter( deserialise_context context, const xmlChar *name )
                {
                        mlt_log_error( NULL, "[producer_xml] filter closed with invalid parent...\n" );
                }
-
-               // Close the dummy filter service
-               mlt_service_close( service );
        }
        else
        {
                mlt_log_error( NULL, "[producer_xml] Invalid top of stack on filter close\n" );
        }
+
+       if ( service )
+       {
+               mlt_service_close( service );
+               free(service);
+       }
 }
 
 static void on_start_transition( deserialise_context context, const xmlChar *name, const xmlChar **atts)
@@ -994,6 +1007,7 @@ static void on_end_transition( deserialise_context context, const xmlChar *name
                        if ( parent )
                                context_push_service( context, parent, parent_type );
                        mlt_service_close( service );
+                       free( service );
                        return;
                }
                track_service( context->destructors, effect, (mlt_destructor) mlt_transition_close );
@@ -1038,13 +1052,17 @@ static void on_end_transition( deserialise_context context, const xmlChar *name
                        mlt_log_error( NULL, "[producer_xml] transition closed with invalid parent...\n" );
                }
 
-               // Close the dummy filter service
-               mlt_service_close( service );
        }
        else
        {
                mlt_log_error( NULL, "[producer_xml] Invalid top of stack on transition close\n" );
        }
+
+       if ( service )
+       {
+               mlt_service_close( service );
+               free( service );
+       }
 }
 
 static void on_start_consumer( deserialise_context context, const xmlChar *name, const xmlChar **atts)