mikey: Free MikeyPayload in error cases

CID #1212135
CID #1212136
CID #1212137
CID #1212138
This commit is contained in:
Edward Hervey 2014-05-12 17:13:50 +02:00
parent 7f9aac386f
commit 3b84e02206

View file

@ -1216,8 +1216,10 @@ gst_mikey_message_add_pke (GstMIKEYMessage * msg, GstMIKEYCacheType C,
g_return_val_if_fail (msg != NULL, FALSE); g_return_val_if_fail (msg != NULL, FALSE);
p = gst_mikey_payload_new (GST_MIKEY_PT_PKE); p = gst_mikey_payload_new (GST_MIKEY_PT_PKE);
if (!gst_mikey_payload_pke_set (p, C, data_len, data)) if (!gst_mikey_payload_pke_set (p, C, data_len, data)) {
gst_mikey_payload_free (p);
return FALSE; return FALSE;
}
return gst_mikey_message_insert_payload (msg, -1, p); return gst_mikey_message_insert_payload (msg, -1, p);
} }
@ -1241,8 +1243,10 @@ gst_mikey_message_add_t (GstMIKEYMessage * msg, GstMIKEYTSType type,
g_return_val_if_fail (msg != NULL, FALSE); g_return_val_if_fail (msg != NULL, FALSE);
p = gst_mikey_payload_new (GST_MIKEY_PT_T); p = gst_mikey_payload_new (GST_MIKEY_PT_T);
if (!gst_mikey_payload_t_set (p, type, ts_value)) if (!gst_mikey_payload_t_set (p, type, ts_value)) {
gst_mikey_payload_free (p);
return FALSE; return FALSE;
}
return gst_mikey_message_insert_payload (msg, -1, p); return gst_mikey_message_insert_payload (msg, -1, p);
} }
@ -1662,6 +1666,7 @@ payloads_from_bytes (ParseState state, GArray * payloads, const guint8 * d,
GstMIKEYPayload *p; GstMIKEYPayload *p;
while (next_payload != GST_MIKEY_PT_LAST) { while (next_payload != GST_MIKEY_PT_LAST) {
p = NULL;
switch (next_payload) { switch (next_payload) {
case GST_MIKEY_PT_KEMAC: case GST_MIKEY_PT_KEMAC:
{ {
@ -1773,7 +1778,6 @@ payloads_from_bytes (ParseState state, GArray * payloads, const guint8 * d,
break; break;
case GST_MIKEY_PT_SP: case GST_MIKEY_PT_SP:
{ {
GstMIKEYPayload *p;
guint8 policy; guint8 policy;
GstMIKEYSecProto proto; GstMIKEYSecProto proto;
guint16 plen; guint16 plen;
@ -1937,11 +1941,15 @@ payloads_from_bytes (ParseState state, GArray * payloads, const guint8 * d,
short_data: short_data:
{ {
GST_DEBUG ("not enough data"); GST_DEBUG ("not enough data");
if (p)
gst_mikey_payload_free (p);
return FALSE; return FALSE;
} }
invalid_data: invalid_data:
{ {
GST_DEBUG ("invalid data"); GST_DEBUG ("invalid data");
if (p)
gst_mikey_payload_free (p);
return FALSE; return FALSE;
} }
} }