summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2014-07-09 07:50:13 +0200
committerEdward Hervey <edward@collabora.com>2014-07-09 07:50:13 +0200
commit7626b494cbd6a4a1d3583a9660247ca2b0790b84 (patch)
tree862e07b8a2cde3592d9508e3c47c74be5d7924da
parent43dd0ec62a7b58e77f0d98099dfe27a8846b3a15 (diff)
downloadgstreamer-plugins-bad-7626b494cbd6a4a1d3583a9660247ca2b0790b84.tar.gz
mpegts: Fix dvb linkage leaks
CID #1224130
-rw-r--r--gst-libs/gst/mpegts/gst-dvb-descriptor.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/gst-libs/gst/mpegts/gst-dvb-descriptor.c b/gst-libs/gst/mpegts/gst-dvb-descriptor.c
index 52638fefc..94328b045 100644
--- a/gst-libs/gst/mpegts/gst-dvb-descriptor.c
+++ b/gst-libs/gst/mpegts/gst-dvb-descriptor.c
@@ -563,21 +563,23 @@ _gst_mpegts_dvb_linkage_descriptor_copy (GstMpegtsDVBLinkageDescriptor * source)
void
gst_mpegts_dvb_linkage_descriptor_free (GstMpegtsDVBLinkageDescriptor * source)
{
- switch (source->linkage_type) {
- case GST_MPEGTS_DVB_LINKAGE_MOBILE_HAND_OVER:
- g_slice_free (GstMpegtsDVBLinkageMobileHandOver, source->linkage_data);
- break;
- case GST_MPEGTS_DVB_LINKAGE_EVENT:
- g_slice_free (GstMpegtsDVBLinkageEvent, source->linkage_data);
- break;
- case GST_MPEGTS_DVB_LINKAGE_EXTENDED_EVENT:
- g_ptr_array_unref (source->linkage_data);
- break;
- default:
- break;
- }
+ if (source->linkage_data)
+ switch (source->linkage_type) {
+ case GST_MPEGTS_DVB_LINKAGE_MOBILE_HAND_OVER:
+ g_slice_free (GstMpegtsDVBLinkageMobileHandOver, source->linkage_data);
+ break;
+ case GST_MPEGTS_DVB_LINKAGE_EVENT:
+ g_slice_free (GstMpegtsDVBLinkageEvent, source->linkage_data);
+ break;
+ case GST_MPEGTS_DVB_LINKAGE_EXTENDED_EVENT:
+ g_ptr_array_unref (source->linkage_data);
+ break;
+ default:
+ break;
+ }
- g_slice_free1 (source->private_data_length, source->private_data_bytes);
+ if (source->private_data_bytes)
+ g_slice_free1 (source->private_data_length, source->private_data_bytes);
g_slice_free (GstMpegtsDVBLinkageDescriptor, source);
}
@@ -635,7 +637,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
GstMpegtsDVBLinkageMobileHandOver *hand_over;
if (end - data < 1)
- return FALSE;
+ goto fail;
hand_over = g_slice_new0 (GstMpegtsDVBLinkageMobileHandOver);
res->linkage_data = (gpointer) hand_over;
@@ -650,22 +652,16 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
GST_MPEGTS_DVB_LINKAGE_HAND_OVER_LOCAL_VARIATION
|| hand_over->hand_over_type ==
GST_MPEGTS_DVB_LINKAGE_HAND_OVER_ASSOCIATED) {
- if (end - data < 2) {
- g_slice_free (GstMpegtsDVBLinkageMobileHandOver, hand_over);
- res->linkage_data = NULL;
- return FALSE;
- }
+ if (end - data < 2)
+ goto fail;
hand_over->network_id = GST_READ_UINT16_BE (data);
data += 2;
}
if (hand_over->origin_type == 0) {
- if (end - data < 2) {
- g_slice_free (GstMpegtsDVBLinkageMobileHandOver, hand_over);
- res->linkage_data = NULL;
- return FALSE;
- }
+ if (end - data < 2)
+ goto fail;
hand_over->initial_service_id = GST_READ_UINT16_BE (data);
data += 2;
@@ -676,7 +672,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
GstMpegtsDVBLinkageEvent *event;
if (end - data < 3)
- return FALSE;
+ goto fail;
event = g_slice_new0 (GstMpegtsDVBLinkageEvent);
res->linkage_data = (gpointer) event;
@@ -765,8 +761,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
return TRUE;
fail:
- g_ptr_array_unref (res->linkage_data);
- res->linkage_data = NULL;
+ gst_mpegts_dvb_linkage_descriptor_free (res);
return FALSE;
}