Skip to content

Commit

Permalink
Fix #945 MLT::Chain leaking memory
Browse files Browse the repository at this point in the history
Ensure the source producer is closed. Memory can lean if it is never
closed.
  • Loading branch information
bmatherly committed Sep 6, 2023
1 parent 2266e5c commit ccb1853
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/framework/mlt_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ void mlt_chain_close(mlt_chain self)
for (i = 0; i < base->link_count; i++)
mlt_link_close(base->links[i]);
free(base->links);
mlt_producer_close(base->source);
mlt_properties_close(base->source_parameters);
mlt_profile_close(base->source_profile);
free(base);
self->parent.close = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/modules/core/producer_melt.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ mlt_producer producer_melt_init(mlt_profile profile,
}
if (producer != NULL && chain != NULL) {
mlt_chain_set_source(chain, producer);
mlt_producer_close(producer);
mlt_chain_attach_normalizers(chain);
producer = MLT_CHAIN_PRODUCER(chain);
} else if (producer != NULL) {
Expand Down
1 change: 1 addition & 0 deletions src/modules/xml/producer_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ static void on_end_chain(deserialise_context context, const xmlChar *name)
mlt_properties_inherit(MLT_PRODUCER_PROPERTIES(source), properties);
// Add the source producer to the chain
mlt_chain_set_source(chain, source);
mlt_producer_close(source);
mlt_chain_attach_normalizers(chain);

// See if the chain should be added to a playlist or multitrack
Expand Down

0 comments on commit ccb1853

Please sign in to comment.