mpegts: Fix dvb linkage leaks

CID #1224130
This commit is contained in:
Edward Hervey 2014-07-09 07:50:13 +02:00
parent 43dd0ec62a
commit 7626b494cb

View file

@ -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;
}