closedcaption: cea708decoder: fix some memory leaks

This commit is contained in:
Tim-Philipp Müller 2019-03-06 23:45:27 +00:00
parent 6dad8b7c78
commit 92e5c5a85a
3 changed files with 28 additions and 0 deletions

View file

@ -123,6 +123,7 @@ gst_cea708dec_clear_window_text (Cea708Dec * decoder, guint window_id);
static void
gst_cea708dec_scroll_window_up (Cea708Dec * decoder, guint window_id);
static void gst_cea708dec_init_window (Cea708Dec * decoder, guint window_id);
static void gst_cea708dec_clear_window (Cea708Dec * decoder, cea708Window * w);
static void
gst_cea708dec_set_pen_attributes (Cea708Dec * decoder,
guint8 * dtvcc_buffer, int index);
@ -174,6 +175,20 @@ gst_cea708dec_create (PangoContext * pango_context)
return decoder;
}
void
gst_cea708dec_free (Cea708Dec * dec)
{
int i;
for (i = 0; i < MAX_708_WINDOWS; i++) {
cea708Window *window = dec->cc_windows[i];
gst_cea708dec_clear_window (dec, window);
g_free (window);
}
memset (dec, 0, sizeof (Cea708Dec));
g_free (dec);
}
void
gst_cea708dec_set_service_number (Cea708Dec * decoder, gint8 desired_service)
{
@ -1298,6 +1313,13 @@ gst_cea708dec_scroll_window_up (Cea708Dec * decoder, guint window_id)
}
}
static void
gst_cea708dec_clear_window (Cea708Dec * decoder, cea708Window * window)
{
g_free (window->text_image);
memset (window, 0, sizeof (cea708Window));
}
static void
gst_cea708dec_init_window (Cea708Dec * decoder, guint window_id)
{

View file

@ -473,6 +473,9 @@ struct _Cea708Dec
};
Cea708Dec *gst_cea708dec_create (PangoContext * pango_context);
void gst_cea708dec_free (Cea708Dec *dec);
void
gst_cea708dec_set_service_number (Cea708Dec * decoder, gint8 desired_service);
gboolean

View file

@ -301,6 +301,9 @@ gst_cea_cc_overlay_finalize (GObject * object)
overlay->next_composition = NULL;
}
gst_cea708dec_free (overlay->decoder);
overlay->decoder = NULL;
g_mutex_clear (&overlay->lock);
g_cond_clear (&overlay->cond);