diff --git a/ext/metadata/gstbasemetadata.c b/ext/metadata/gstbasemetadata.c index 0d7f3d6d1a..6f13851ae1 100644 --- a/ext/metadata/gstbasemetadata.c +++ b/ext/metadata/gstbasemetadata.c @@ -526,8 +526,6 @@ gst_base_metadata_reset_streaming (GstBaseMetadata * filter) static void gst_base_metadata_reset_parsing (GstBaseMetadata * filter) { - - if (filter->prepend_buffer) { gst_buffer_unref (filter->prepend_buffer); filter->prepend_buffer = NULL; @@ -1991,18 +1989,13 @@ void gst_base_metadata_update_inject_segment_with_new_data MetadataChunk *inject = META_DATA_INJECT_CHUNKS (base->metadata).chunk; const gsize inject_len = META_DATA_INJECT_CHUNKS (base->metadata).len; - if (!(data && size)) - goto done; - if (*data == 0) - goto done; - if (*size == 0) + if (!(data && size && *data && *size)) goto done; for (i = 0; i < inject_len; ++i) { if (inject[i].type == type) { inject[i].size = *size; - if (inject[i].data) - g_free (inject[i].data); + g_free (inject[i].data); inject[i].data = *data; *size = 0; *data = 0; diff --git a/ext/metadata/gstmetadatamux.c b/ext/metadata/gstmetadatamux.c index 76f963f6ac..626a40db14 100644 --- a/ext/metadata/gstmetadatamux.c +++ b/ext/metadata/gstmetadatamux.c @@ -394,12 +394,12 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base) GstMetadataMux *filter = GST_METADATA_MUX (base); GstTagSetter *setter = GST_TAG_SETTER (filter); const GstTagList *taglist = gst_tag_setter_get_tag_list (setter); - guint8 *buf = NULL; - guint32 size = 0; GST_DEBUG_OBJECT (base, "Creating chunks from tags.."); if (taglist) { + guint8 *buf = NULL; + guint32 size = 0; if (gst_base_metadata_get_option_flag (base) & META_OPT_EXIF) { GST_DEBUG_OBJECT (base, "Using EXIF"); @@ -407,6 +407,9 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base) &filter->exif_options); gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size, MD_CHUNK_EXIF); + g_free (buf); + buf = NULL; + size = 0; } if (gst_base_metadata_get_option_flag (base) & META_OPT_IPTC) { @@ -414,6 +417,9 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base) metadatamux_iptc_create_chunk_from_tag_list (&buf, &size, taglist); gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size, MD_CHUNK_IPTC); + g_free (buf); + buf = NULL; + size = 0; } if (gst_base_metadata_get_option_flag (base) & META_OPT_XMP) { @@ -421,18 +427,13 @@ gst_metadata_mux_create_chunks_from_tags (GstBaseMetadata * base) metadatamux_xmp_create_chunk_from_tag_list (&buf, &size, taglist); gst_base_metadata_update_inject_segment_with_new_data (base, &buf, &size, MD_CHUNK_XMP); + g_free (buf); } - } - - else { + } else { GST_DEBUG_OBJECT (base, "Empty taglist"); } - if (buf) { - g_free (buf); - } - } static gboolean diff --git a/ext/metadata/metadataexif.c b/ext/metadata/metadataexif.c index 0f7766d627..11491fa5fa 100644 --- a/ext/metadata/metadataexif.c +++ b/ext/metadata/metadataexif.c @@ -388,10 +388,9 @@ metadatamux_exif_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, if (!(buf && size)) goto done; - if (*buf) { - g_free (*buf); - *buf = NULL; - } + + g_free (*buf); + *buf = NULL; *size = 0; val = gst_tag_list_get_value_index (taglist, GST_TAG_EXIF, 0); diff --git a/ext/metadata/metadataiptc.c b/ext/metadata/metadataiptc.c index 167ce1d65a..b3baabdda2 100644 --- a/ext/metadata/metadataiptc.c +++ b/ext/metadata/metadataiptc.c @@ -252,10 +252,9 @@ metadatamux_iptc_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, if (!(buf && size)) goto done; - if (*buf) { - g_free (*buf); - *buf = NULL; - } + + g_free (*buf); + *buf = NULL; *size = 0; val = gst_tag_list_get_value_index (taglist, GST_TAG_IPTC, 0); diff --git a/ext/metadata/metadatatypes.c b/ext/metadata/metadatatypes.c index 16a72e07f9..c1744fd059 100644 --- a/ext/metadata/metadatatypes.c +++ b/ext/metadata/metadatatypes.c @@ -99,10 +99,8 @@ metadata_chunk_array_free (MetadataChunkArray * array) { metadata_chunk_array_clear (array); array->allocated_len = 0; - if (array->chunk) { - g_free (array->chunk); - array->chunk = NULL; - } + g_free (array->chunk); + array->chunk = NULL; } /* @@ -121,9 +119,7 @@ metadata_chunk_array_clear (MetadataChunkArray * array) { while (array->len) { array->len--; - if (array->chunk[array->len].data) { - g_free (array->chunk[array->len].data); - } + g_free (array->chunk[array->len].data); } } @@ -239,8 +235,7 @@ metadata_chunk_array_remove_by_index (MetadataChunkArray * array, guint32 i) { if (i < array->len) { - if (array->chunk[i].data) - g_free (array->chunk[i].data); + g_free (array->chunk[i].data); if (i < --array->len) { memmove (&array->chunk[i], &array->chunk[i + 1], sizeof (MetadataChunk) * (array->len - i)); diff --git a/ext/metadata/metadataxmp.c b/ext/metadata/metadataxmp.c index 9f787c7ed7..fc9fb42523 100644 --- a/ext/metadata/metadataxmp.c +++ b/ext/metadata/metadataxmp.c @@ -362,10 +362,9 @@ metadatamux_xmp_create_chunk_from_tag_list (guint8 ** buf, guint32 * size, if (!(buf && size)) goto done; - if (*buf) { - g_free (*buf); - *buf = NULL; - } + + g_free (*buf); + *buf = NULL; *size = 0; val = gst_tag_list_get_value_index (taglist, GST_TAG_XMP, 0);