From b1f78b5d23db1700eaabfc647806ba1ace9f00b3 Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Wed, 19 Aug 2015 21:19:05 +0900 Subject: [PATCH] subparse: use g_clear_error instead of g_error_free To avoid invalid pointer accees the err pointer should be set to NULL. By using g_clear_error() it calls free and clear the pointer. https://bugzilla.gnome.org/show_bug.cgi?id=753817 --- gst/subparse/gstsubparse.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index d81b8a4d41..5dadb0a336 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -452,7 +452,7 @@ convert_encoding (GstSubParse * self, const gchar * str, gsize len, self->detected_encoding, err->message); g_free (self->detected_encoding); self->detected_encoding = NULL; - g_error_free (err); + g_clear_error (&err); } /* Otherwise check if it's UTF8 */ @@ -484,7 +484,7 @@ convert_encoding (GstSubParse * self, const gchar * str, gsize len, if (err) { GST_WARNING_OBJECT (self, "could not convert string from '%s' to UTF-8: %s", encoding, err->message); - g_error_free (err); + 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); @@ -1214,7 +1214,7 @@ gst_sub_parse_data_format_autodetect_regex_once (GstSubParseRegex regtype) G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr); if (result == NULL) { g_warning ("Compilation of mdvd regex failed: %s", gerr->message); - g_error_free (gerr); + g_clear_error (&gerr); } break; case GST_SUB_PARSE_REGEX_SUBRIP: @@ -1225,7 +1225,7 @@ gst_sub_parse_data_format_autodetect_regex_once (GstSubParseRegex regtype) G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr); if (result == NULL) { g_warning ("Compilation of subrip regex failed: %s", gerr->message); - g_error_free (gerr); + g_clear_error (&gerr); } break; case GST_SUB_PARSE_REGEX_DKS: @@ -1233,7 +1233,7 @@ gst_sub_parse_data_format_autodetect_regex_once (GstSubParseRegex regtype) G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &gerr); if (result == NULL) { g_warning ("Compilation of dks regex failed: %s", gerr->message); - g_error_free (gerr); + g_clear_error (&gerr); } break; default: @@ -1764,7 +1764,7 @@ gst_subparse_type_find (GstTypeFind * tf, gpointer private) if (converted_str == NULL) { GST_DEBUG ("Encoding '%s' detected but conversion failed: %s", encoding, err->message); - g_error_free (err); + g_clear_error (&err); } else { g_free (str); str = converted_str;