subparse: conditionally cleanup sami context

Only cleanup sami context if we are parsing sami subtitles,
otherwise we might have crashes.
This commit is contained in:
Thiago Santos 2009-12-01 13:22:57 -03:00
parent 12db385ada
commit c4b86b37fb

View file

@ -163,7 +163,8 @@ gst_sub_parse_dispose (GObject * object)
subparse->textbuf = NULL; subparse->textbuf = NULL;
} }
#ifndef GST_DISABLE_XML #ifndef GST_DISABLE_XML
sami_context_deinit (&subparse->state); if (subparse->parser_type == GST_SUB_PARSE_FORMAT_SAMI)
sami_context_deinit (&subparse->state);
#endif #endif
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
@ -1189,14 +1190,14 @@ parser_state_init (ParserState * state)
} }
static void static void
parser_state_dispose (ParserState * state) parser_state_dispose (GstSubParse * self, ParserState * state)
{ {
if (state->buf) { if (state->buf) {
g_string_free (state->buf, TRUE); g_string_free (state->buf, TRUE);
state->buf = NULL; state->buf = NULL;
} }
#ifndef GST_DISABLE_XML #ifndef GST_DISABLE_XML
if (state->user_data) { if (state->user_data && self->parser_type == GST_SUB_PARSE_FORMAT_SAMI) {
sami_context_reset (state); sami_context_reset (state);
} }
#endif #endif
@ -1670,7 +1671,7 @@ gst_sub_parse_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:
parser_state_dispose (&self->state); parser_state_dispose (self, &self->state);
self->parser_type = GST_SUB_PARSE_FORMAT_UNKNOWN; self->parser_type = GST_SUB_PARSE_FORMAT_UNKNOWN;
break; break;
default: default: