mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-25 23:46:45 +00:00
toc: fix memory leaks while copying content
This commit is contained in:
parent
fd2ebb5365
commit
feb19b6f60
1 changed files with 45 additions and 18 deletions
63
gst/gsttoc.c
63
gst/gsttoc.c
|
@ -228,6 +228,7 @@ gst_toc_entry_new_with_pad (GstTocEntryType type, const gchar * uid,
|
||||||
entry->uid = g_strdup (uid);
|
entry->uid = g_strdup (uid);
|
||||||
entry->type = type;
|
entry->type = type;
|
||||||
entry->tags = gst_tag_list_new_empty ();
|
entry->tags = gst_tag_list_new_empty ();
|
||||||
|
entry->info = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_INFONAME]);
|
||||||
|
|
||||||
if (pad != NULL && GST_IS_PAD (pad))
|
if (pad != NULL && GST_IS_PAD (pad))
|
||||||
entry->pads = g_list_append (entry->pads, gst_object_ref (pad));
|
entry->pads = g_list_append (entry->pads, gst_object_ref (pad));
|
||||||
|
@ -397,8 +398,9 @@ gst_toc_entry_from_structure (const GstStructure * entry, guint level)
|
||||||
{
|
{
|
||||||
GstTocEntry *ret, *subentry;
|
GstTocEntry *ret, *subentry;
|
||||||
const GValue *val;
|
const GValue *val;
|
||||||
const GstTagList *entry_tags;
|
|
||||||
const GstStructure *subentry_struct;
|
const GstStructure *subentry_struct;
|
||||||
|
GstTagList *list;
|
||||||
|
GstStructure *st;
|
||||||
gint count, i;
|
gint count, i;
|
||||||
const gchar *uid;
|
const gchar *uid;
|
||||||
guint chapters_count = 0, editions_count = 0;
|
guint chapters_count = 0, editions_count = 0;
|
||||||
|
@ -463,8 +465,9 @@ gst_toc_entry_from_structure (const GstStructure * entry, guint level)
|
||||||
val = gst_structure_id_get_value (entry, gst_toc_fields[GST_TOC_TAGS]);
|
val = gst_structure_id_get_value (entry, gst_toc_fields[GST_TOC_TAGS]);
|
||||||
|
|
||||||
if (G_LIKELY (GST_IS_TAG_LIST (gst_value_get_structure (val)))) {
|
if (G_LIKELY (GST_IS_TAG_LIST (gst_value_get_structure (val)))) {
|
||||||
entry_tags = GST_TAG_LIST (gst_value_get_structure (val));
|
list = gst_tag_list_copy (GST_TAG_LIST (gst_value_get_structure (val)));
|
||||||
ret->tags = gst_tag_list_copy (entry_tags);
|
gst_tag_list_free (ret->tags);
|
||||||
|
ret->tags = list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,8 +475,11 @@ gst_toc_entry_from_structure (const GstStructure * entry, guint level)
|
||||||
gst_toc_fields[GST_TOC_INFO], GST_TYPE_STRUCTURE)) {
|
gst_toc_fields[GST_TOC_INFO], GST_TYPE_STRUCTURE)) {
|
||||||
val = gst_structure_id_get_value (entry, gst_toc_fields[GST_TOC_INFO]);
|
val = gst_structure_id_get_value (entry, gst_toc_fields[GST_TOC_INFO]);
|
||||||
|
|
||||||
if (G_LIKELY (GST_IS_STRUCTURE (gst_value_get_structure (val))))
|
if (G_LIKELY (GST_IS_STRUCTURE (gst_value_get_structure (val)))) {
|
||||||
ret->info = gst_structure_copy (gst_value_get_structure (val));
|
st = gst_structure_copy (gst_value_get_structure (val));
|
||||||
|
gst_structure_free (ret->info);
|
||||||
|
ret->info = st;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -486,7 +492,8 @@ __gst_toc_from_structure (const GstStructure * toc)
|
||||||
GstTocEntry *subentry;
|
GstTocEntry *subentry;
|
||||||
const GstStructure *subentry_struct;
|
const GstStructure *subentry_struct;
|
||||||
const GValue *val;
|
const GValue *val;
|
||||||
const GstTagList *entry_tags;
|
GstTagList *list;
|
||||||
|
GstStructure *st;
|
||||||
guint count, i;
|
guint count, i;
|
||||||
guint editions_count = 0, chapters_count = 0;
|
guint editions_count = 0, chapters_count = 0;
|
||||||
|
|
||||||
|
@ -542,8 +549,9 @@ __gst_toc_from_structure (const GstStructure * toc)
|
||||||
val = gst_structure_id_get_value (toc, gst_toc_fields[GST_TOC_TAGS]);
|
val = gst_structure_id_get_value (toc, gst_toc_fields[GST_TOC_TAGS]);
|
||||||
|
|
||||||
if (G_LIKELY (GST_IS_TAG_LIST (gst_value_get_structure (val)))) {
|
if (G_LIKELY (GST_IS_TAG_LIST (gst_value_get_structure (val)))) {
|
||||||
entry_tags = GST_TAG_LIST (gst_value_get_structure (val));
|
list = gst_tag_list_copy (GST_TAG_LIST (gst_value_get_structure (val)));
|
||||||
ret->tags = gst_tag_list_copy (entry_tags);
|
gst_tag_list_free (ret->tags);
|
||||||
|
ret->tags = list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,8 +559,11 @@ __gst_toc_from_structure (const GstStructure * toc)
|
||||||
gst_toc_fields[GST_TOC_INFO], GST_TYPE_STRUCTURE)) {
|
gst_toc_fields[GST_TOC_INFO], GST_TYPE_STRUCTURE)) {
|
||||||
val = gst_structure_id_get_value (toc, gst_toc_fields[GST_TOC_INFO]);
|
val = gst_structure_id_get_value (toc, gst_toc_fields[GST_TOC_INFO]);
|
||||||
|
|
||||||
if (G_LIKELY (GST_IS_STRUCTURE (gst_value_get_structure (val))))
|
if (G_LIKELY (GST_IS_STRUCTURE (gst_value_get_structure (val)))) {
|
||||||
ret->info = gst_structure_copy (gst_value_get_structure (val));
|
st = gst_structure_copy (gst_value_get_structure (val));
|
||||||
|
gst_structure_free (ret->info);
|
||||||
|
ret->info = st;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_UNLIKELY (ret->entries == NULL)) {
|
if (G_UNLIKELY (ret->entries == NULL)) {
|
||||||
|
@ -782,16 +793,24 @@ gst_toc_entry_copy (const GstTocEntry * entry)
|
||||||
{
|
{
|
||||||
GstTocEntry *ret, *sub;
|
GstTocEntry *ret, *sub;
|
||||||
GList *cur;
|
GList *cur;
|
||||||
|
GstTagList *list;
|
||||||
|
GstStructure *st;
|
||||||
|
|
||||||
g_return_val_if_fail (entry != NULL, NULL);
|
g_return_val_if_fail (entry != NULL, NULL);
|
||||||
|
|
||||||
ret = gst_toc_entry_new (entry->type, entry->uid);
|
ret = gst_toc_entry_new (entry->type, entry->uid);
|
||||||
|
|
||||||
if (GST_IS_STRUCTURE (entry->info))
|
if (GST_IS_STRUCTURE (entry->info)) {
|
||||||
ret->info = gst_structure_copy (entry->info);
|
st = gst_structure_copy (entry->info);
|
||||||
|
gst_structure_free (ret->info);
|
||||||
|
ret->info = st;
|
||||||
|
}
|
||||||
|
|
||||||
if (GST_IS_TAG_LIST (entry->tags))
|
if (GST_IS_TAG_LIST (entry->tags)) {
|
||||||
ret->tags = gst_tag_list_copy (entry->tags);
|
list = gst_tag_list_copy (entry->tags);
|
||||||
|
gst_tag_list_free (ret->tags);
|
||||||
|
ret->tags = list;
|
||||||
|
}
|
||||||
|
|
||||||
cur = entry->pads;
|
cur = entry->pads;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
|
@ -832,16 +851,24 @@ gst_toc_copy (const GstToc * toc)
|
||||||
GstToc *ret;
|
GstToc *ret;
|
||||||
GstTocEntry *entry;
|
GstTocEntry *entry;
|
||||||
GList *cur;
|
GList *cur;
|
||||||
|
GstTagList *list;
|
||||||
|
GstStructure *st;
|
||||||
|
|
||||||
g_return_val_if_fail (toc != NULL, NULL);
|
g_return_val_if_fail (toc != NULL, NULL);
|
||||||
|
|
||||||
ret = gst_toc_new ();
|
ret = gst_toc_new ();
|
||||||
|
|
||||||
if (GST_IS_STRUCTURE (toc->info))
|
if (GST_IS_STRUCTURE (toc->info)) {
|
||||||
ret->info = gst_structure_copy (toc->info);
|
st = gst_structure_copy (toc->info);
|
||||||
|
gst_structure_free (ret->info);
|
||||||
|
ret->info = st;
|
||||||
|
}
|
||||||
|
|
||||||
if (GST_IS_TAG_LIST (toc->tags))
|
if (GST_IS_TAG_LIST (toc->tags)) {
|
||||||
ret->tags = gst_tag_list_copy (toc->tags);
|
list = gst_tag_list_copy (toc->tags);
|
||||||
|
gst_tag_list_free (ret->tags);
|
||||||
|
ret->tags = list;
|
||||||
|
}
|
||||||
|
|
||||||
cur = toc->entries;
|
cur = toc->entries;
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
|
|
Loading…
Reference in a new issue