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,6 +563,7 @@ _gst_mpegts_dvb_linkage_descriptor_copy (GstMpegtsDVBLinkageDescriptor * source)
void void
gst_mpegts_dvb_linkage_descriptor_free (GstMpegtsDVBLinkageDescriptor * source) gst_mpegts_dvb_linkage_descriptor_free (GstMpegtsDVBLinkageDescriptor * source)
{ {
if (source->linkage_data)
switch (source->linkage_type) { switch (source->linkage_type) {
case GST_MPEGTS_DVB_LINKAGE_MOBILE_HAND_OVER: case GST_MPEGTS_DVB_LINKAGE_MOBILE_HAND_OVER:
g_slice_free (GstMpegtsDVBLinkageMobileHandOver, source->linkage_data); g_slice_free (GstMpegtsDVBLinkageMobileHandOver, source->linkage_data);
@ -577,6 +578,7 @@ gst_mpegts_dvb_linkage_descriptor_free (GstMpegtsDVBLinkageDescriptor * source)
break; break;
} }
if (source->private_data_bytes)
g_slice_free1 (source->private_data_length, source->private_data_bytes); g_slice_free1 (source->private_data_length, source->private_data_bytes);
g_slice_free (GstMpegtsDVBLinkageDescriptor, source); g_slice_free (GstMpegtsDVBLinkageDescriptor, source);
} }
@ -635,7 +637,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
GstMpegtsDVBLinkageMobileHandOver *hand_over; GstMpegtsDVBLinkageMobileHandOver *hand_over;
if (end - data < 1) if (end - data < 1)
return FALSE; goto fail;
hand_over = g_slice_new0 (GstMpegtsDVBLinkageMobileHandOver); hand_over = g_slice_new0 (GstMpegtsDVBLinkageMobileHandOver);
res->linkage_data = (gpointer) hand_over; 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 GST_MPEGTS_DVB_LINKAGE_HAND_OVER_LOCAL_VARIATION
|| hand_over->hand_over_type == || hand_over->hand_over_type ==
GST_MPEGTS_DVB_LINKAGE_HAND_OVER_ASSOCIATED) { GST_MPEGTS_DVB_LINKAGE_HAND_OVER_ASSOCIATED) {
if (end - data < 2) { if (end - data < 2)
g_slice_free (GstMpegtsDVBLinkageMobileHandOver, hand_over); goto fail;
res->linkage_data = NULL;
return FALSE;
}
hand_over->network_id = GST_READ_UINT16_BE (data); hand_over->network_id = GST_READ_UINT16_BE (data);
data += 2; data += 2;
} }
if (hand_over->origin_type == 0) { if (hand_over->origin_type == 0) {
if (end - data < 2) { if (end - data < 2)
g_slice_free (GstMpegtsDVBLinkageMobileHandOver, hand_over); goto fail;
res->linkage_data = NULL;
return FALSE;
}
hand_over->initial_service_id = GST_READ_UINT16_BE (data); hand_over->initial_service_id = GST_READ_UINT16_BE (data);
data += 2; data += 2;
@ -676,7 +672,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
GstMpegtsDVBLinkageEvent *event; GstMpegtsDVBLinkageEvent *event;
if (end - data < 3) if (end - data < 3)
return FALSE; goto fail;
event = g_slice_new0 (GstMpegtsDVBLinkageEvent); event = g_slice_new0 (GstMpegtsDVBLinkageEvent);
res->linkage_data = (gpointer) event; res->linkage_data = (gpointer) event;
@ -765,8 +761,7 @@ gst_mpegts_descriptor_parse_dvb_linkage (const GstMpegtsDescriptor * descriptor,
return TRUE; return TRUE;
fail: fail:
g_ptr_array_unref (res->linkage_data); gst_mpegts_dvb_linkage_descriptor_free (res);
res->linkage_data = NULL;
return FALSE; return FALSE;
} }