From 4115f010b550c75326c3567aefcd3368cb73f0e2 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Thu, 25 Oct 2018 19:42:23 +0900 Subject: [PATCH] subparse: apply missed patch - resolve mem leak - handle encoding error - handle end body state Change-Id: I85f48fd6d7974501e45ee736d70e7c22db6d52bd --- gst/subparse/gstsubparse.c | 29 ++++++++++++++++++++--------- gst/subparse/samiparse.c | 3 ++- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index a8c0438..f5e2a2f 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -127,10 +127,8 @@ gst_sub_parse_dispose (GObject * object) } #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION - if (subparse->state.current_language) { - g_free (subparse->state.current_language); - subparse->state.current_language = NULL; - } + g_free (subparse->state.current_language); + subparse->state.current_language = NULL; g_mutex_clear (&subparse->seek_lock); #endif @@ -364,9 +362,7 @@ gst_sub_parse_set_property (GObject * object, guint prop_id, } #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION case PROP_EXTSUB_CURRENT_LANGUAGE: - if (subparse->state.current_language) - g_free(subparse->state.current_language); - + g_free(subparse->state.current_language); subparse->state.current_language = g_value_dup_string (value); GST_LOG_OBJECT (subparse, "subtitle current language set to %s", GST_STR_NULL (subparse->state.current_language)); @@ -542,8 +538,20 @@ convert_encoding (GstSubParse * self, const gchar * str, gsize len, encoding, err->message); g_clear_error (&err); - /* invalid input encoding, fall back to ISO-8859-15 (always succeeds) */ - ret = gst_convert_to_utf8 (str, len, "ISO-8859-15", consumed, NULL); +#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION + if (!strcmp (self->encoding, "EUC-KR")) { + GST_WARNING ("fallback case occured with EUC-KR, so going with CP949"); + g_free (self->encoding); + self->encoding = g_strdup ("CP949"); + encoding = self->encoding; + ret = gst_convert_to_utf8 (str, len, encoding, consumed, &err); + } else { +#endif + /* invalid input encoding, fall back to ISO-8859-15 (always succeeds) */ + ret = gst_convert_to_utf8 (str, len, "ISO-8859-15", consumed, NULL); +#ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION + } +#endif } GST_LOG_OBJECT (self, @@ -1420,7 +1428,10 @@ parser_state_init (ParserState * state) #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION state->language_list = NULL; + + g_free(state->current_language); state->current_language = NULL; + state->langlist_msg_posted = FALSE; #endif } diff --git a/gst/subparse/samiparse.c b/gst/subparse/samiparse.c index 50c26e8..8d614c9 100644 --- a/gst/subparse/samiparse.c +++ b/gst/subparse/samiparse.c @@ -1245,7 +1245,7 @@ parse_sami (ParserState * state, const gchar * line) g_free (unescaped); #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION if (context->desired_language && context->current_language) { - if (!strcmp(context->current_language, context->desired_language)) { + if ((!strcmp(context->current_language, context->desired_language)) || context->end_body) { #endif if (context->has_result) { if (context->rubybuf->len) { @@ -1261,6 +1261,7 @@ parse_sami (ParserState * state, const gchar * line) context->has_result = FALSE; } #ifdef TIZEN_FEATURE_SUBPARSE_MODIFICATION + context->end_body = FALSE; } } #endif -- 2.7.4