xmlformatter: Plug various leaks

This commit is contained in:
Thibault Saunier 2012-12-29 19:34:29 -03:00
parent cf93469fa5
commit 0ec78ea70b
2 changed files with 38 additions and 21 deletions

View file

@ -124,9 +124,9 @@ static GMarkupParseContext *
create_parser_context (GESBaseXmlFormatter * self, const gchar * uri, create_parser_context (GESBaseXmlFormatter * self, const gchar * uri,
GError ** error) GError ** error)
{ {
GFile *file;
gsize xmlsize; gsize xmlsize;
gchar *xmlcontent; GFile *file = NULL;
gchar *xmlcontent = NULL;
GMarkupParseContext *parsecontext = NULL; GMarkupParseContext *parsecontext = NULL;
GESBaseXmlFormatterClass *self_class = GESBaseXmlFormatterClass *self_class =
GES_BASE_XML_FORMATTER_GET_CLASS (self); GES_BASE_XML_FORMATTER_GET_CLASS (self);
@ -147,21 +147,29 @@ create_parser_context (GESBaseXmlFormatter * self, const gchar * uri,
&err) == FALSE) &err) == FALSE)
goto failed; goto failed;
done:
if (xmlcontent)
g_free (xmlcontent);
if (file)
g_object_unref (file);
return parsecontext; return parsecontext;
wrong_uri: wrong_uri:
GST_WARNING ("%s wrong uri", uri); GST_WARNING ("%s wrong uri", uri);
return NULL;
goto done;
failed: failed:
g_propagate_error (error, err); g_propagate_error (error, err);
if (parsecontext) if (parsecontext) {
g_markup_parse_context_free (parsecontext); g_markup_parse_context_free (parsecontext);
parsecontext = NULL;
}
g_object_unref (file); goto done;
return NULL;
} }
/*********************************************** /***********************************************
@ -173,6 +181,7 @@ failed:
static gboolean static gboolean
_can_load_uri (GESFormatterClass * class, const gchar * uri, GError ** error) _can_load_uri (GESFormatterClass * class, const gchar * uri, GError ** error)
{ {
gboolean ret = FALSE;
GMarkupParseContext *ctx; GMarkupParseContext *ctx;
/* we create a temporary object so we can use it as a context */ /* we create a temporary object so we can use it as a context */
@ -182,11 +191,14 @@ _can_load_uri (GESFormatterClass * class, const gchar * uri, GError ** error)
ctx = create_parser_context (self, uri, error); ctx = create_parser_context (self, uri, error);
if (!ctx) if (!ctx)
return FALSE; goto done;
ret = TRUE;
g_markup_parse_context_free (ctx); g_markup_parse_context_free (ctx);
return TRUE; done:
g_object_unref (self);
return ret;
} }
static gboolean static gboolean
@ -799,8 +811,12 @@ ges_base_xml_formatter_add_track (GESBaseXmlFormatter * self,
GESTrack *track; GESTrack *track;
GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self); GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
if (priv->check_only) if (priv->check_only) {
if (caps)
gst_caps_unref (caps);
return; return;
}
track = ges_track_new (track_type, caps); track = ges_track_new (track_type, caps);
ges_timeline_add_track (GES_FORMATTER (self)->timeline, track); ges_timeline_add_track (GES_FORMATTER (self)->timeline, track);
@ -908,7 +924,7 @@ ges_base_xml_formatter_add_encoding_profile (GESBaseXmlFormatter * self,
GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self); GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
if (priv->check_only) if (priv->check_only)
return; goto done;
if (parent == NULL) { if (parent == NULL) {
profile = profile =
@ -917,7 +933,7 @@ ges_base_xml_formatter_add_encoding_profile (GESBaseXmlFormatter * self,
ges_project_add_encoding_profile (GES_FORMATTER (self)->project, profile); ges_project_add_encoding_profile (GES_FORMATTER (self)->project, profile);
gst_object_unref (profile); gst_object_unref (profile);
return; goto done;
} }
for (tmp = ges_project_list_encoding_profiles (GES_FORMATTER (self)->project); for (tmp = ges_project_list_encoding_profiles (GES_FORMATTER (self)->project);
@ -930,7 +946,7 @@ ges_base_xml_formatter_add_encoding_profile (GESBaseXmlFormatter * self,
if (!GST_IS_ENCODING_CONTAINER_PROFILE (tmpprofile)) { if (!GST_IS_ENCODING_CONTAINER_PROFILE (tmpprofile)) {
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
"Profile '%s' parent %s is not a container...'", name, parent); "Profile '%s' parent %s is not a container...'", name, parent);
return; goto done;
} }
parent_profile = GST_ENCODING_CONTAINER_PROFILE (tmpprofile); parent_profile = GST_ENCODING_CONTAINER_PROFILE (tmpprofile);
@ -941,7 +957,7 @@ ges_base_xml_formatter_add_encoding_profile (GESBaseXmlFormatter * self,
if (parent_profile == NULL) { if (parent_profile == NULL) {
g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT, g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
"Profile '%s' parent %s does not exist'", name, parent); "Profile '%s' parent %s does not exist'", name, parent);
return; goto done;
} }
profile = profile =
@ -949,7 +965,13 @@ ges_base_xml_formatter_add_encoding_profile (GESBaseXmlFormatter * self,
preset_name, id, presence, restriction, pass, variableframerate); preset_name, id, presence, restriction, pass, variableframerate);
if (profile == NULL) if (profile == NULL)
return; goto done;
gst_encoding_container_profile_add_profile (parent_profile, profile); gst_encoding_container_profile_add_profile (parent_profile, profile);
done:
if (format)
gst_caps_unref (format);
if (restriction)
gst_caps_unref (restriction);
} }

View file

@ -216,11 +216,6 @@ _parse_stream_profile (GMarkupParseContext * context,
type, parent, name, description, format_caps, preset, preset_name, id, type, parent, name, description, format_caps, preset, preset_name, id,
presence, restriction_caps, pass, variableframerate, NULL, error); presence, restriction_caps, pass, variableframerate, NULL, error);
if (format_caps)
gst_caps_unref (format_caps);
if (restriction_caps)
gst_caps_unref (restriction_caps);
return; return;
convertion_failed: convertion_failed:
@ -332,7 +327,6 @@ _parse_track (GMarkupParseContext * context, const gchar * element_name,
if (errno) if (errno)
goto convertion_failed; goto convertion_failed;
/* TODO Implemet IDs */
ges_base_xml_formatter_add_track (GES_BASE_XML_FORMATTER (self), track_type, ges_base_xml_formatter_add_track (GES_BASE_XML_FORMATTER (self), track_type,
caps, strtrack_id, NULL, metadatas, error); caps, strtrack_id, NULL, metadatas, error);
@ -345,6 +339,7 @@ wrong_caps:
return; return;
convertion_failed: convertion_failed:
gst_caps_unref (caps);
g_set_error (error, G_MARKUP_ERROR, g_set_error (error, G_MARKUP_ERROR,
G_MARKUP_ERROR_INVALID_CONTENT, G_MARKUP_ERROR_INVALID_CONTENT,
"element '%s', Wrong property type, error: %s'", element_name, "element '%s', Wrong property type, error: %s'", element_name,