subparse: apply missed patch 24/191924/1 accepted/tizen/unified/20181113.163401 submit/tizen/20181107.091634
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 25 Oct 2018 10:42:23 +0000 (19:42 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 25 Oct 2018 10:42:24 +0000 (19:42 +0900)
- resolve mem leak
- handle encoding error
- handle end body state

Change-Id: I85f48fd6d7974501e45ee736d70e7c22db6d52bd

gst/subparse/gstsubparse.c
gst/subparse/samiparse.c

index a8c0438..f5e2a2f 100644 (file)
@@ -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
 }
index 50c26e8..8d614c9 100644 (file)
@@ -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