rtph263pay: Fix leak for B-fragments

Altough commits 6a16be7, 64f9d08 and 0c7e3a8 fixed some issues they
introduced others. This patch fixes the leak of one macroblock for every
B fragment.

Macroblock structures must not be freed immediately after finding the
boundaries as they are stored and used later. However the inital dummy
structure (used for finding the first boundary) must be freed.

CID #1212156

https://bugzilla.gnome.org/show_bug.cgi?id=773512
This commit is contained in:
Stian Selnes 2016-10-18 11:09:10 +02:00 committed by Sebastian Dröge
parent 6e7816c589
commit bcff182fd9

View file

@ -970,9 +970,6 @@ gst_rtp_h263_pay_B_mbfinder (GstRtpH263PayContext * context,
GST_LOG ("current_pos:%p, end:%p, rest_bits:%d, window:%x",
mac->start, mac->end, macroblock->ebit, context->window);
/* macroblock isn't needed anymore */
gst_rtp_h263_pay_mb_destroy (macroblock);
GST_LOG ("Current pos after COD: %p", mac->end);
if (context->piclayer->ptype_pictype == 0) {
@ -1412,7 +1409,7 @@ gst_rtp_h263_pay_mode_B_fragment (GstRtpH263Pay * rtph263pay,
/*---------- MODE B MODE FRAGMENTATION ----------*/
GstRtpH263PayMB *mac;
GstRtpH263PayMB *mac, *mac0;
guint max_payload_size;
GstRtpH263PayBoundry boundry;
guint mb;
@ -1508,7 +1505,7 @@ gst_rtp_h263_pay_mode_B_fragment (GstRtpH263Pay * rtph263pay,
// We are on MB layer
mac = gst_rtp_h263_pay_mb_new (&boundry, 0);
mac = mac0 = gst_rtp_h263_pay_mb_new (&boundry, 0);
for (mb = 0; mb < format_props[context->piclayer->ptype_srcformat][1]; mb++) {
GST_LOG ("================ START MB %d =================", mb);
@ -1520,9 +1517,12 @@ gst_rtp_h263_pay_mode_B_fragment (GstRtpH263Pay * rtph263pay,
GST_LOG ("Error decoding MB - sbit: %d", 8 - ebit);
GST_ERROR ("Error decoding in GOB");
gst_rtp_h263_pay_mb_destroy (mac0);
goto decode_error;
}
/* Store macroblock for further processing and delete old MB if any */
gst_rtp_h263_pay_mb_destroy (gob->macroblocks[mb]);
gob->macroblocks[mb] = mac;
//If mb_type == stuffing, don't increment the mb address
@ -1545,6 +1545,7 @@ gst_rtp_h263_pay_mode_B_fragment (GstRtpH263Pay * rtph263pay,
mac->mba, mac->start, mac->end, mac->length, mac->sbit, mac->ebit);
GST_LOG ("================ END MB %d =================", mb);
}
gst_rtp_h263_pay_mb_destroy (mac0);
mb = 0;
first = 0;