[totem-pl-parser] plparser: Simplify error paths
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem-pl-parser] plparser: Simplify error paths
- Date: Thu, 4 Mar 2021 14:07:07 +0000 (UTC)
commit d72d98383a77ff8d0a9c0728d7db5e8f917cfed2
Author: Bastien Nocera <hadess hadess net>
Date: Thu Mar 4 13:57:41 2021 +0100
plparser: Simplify error paths
plparse/totem-pl-parser.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/plparse/totem-pl-parser.c b/plparse/totem-pl-parser.c
index dd65b71..dc34a23 100644
--- a/plparse/totem-pl-parser.c
+++ b/plparse/totem-pl-parser.c
@@ -1852,7 +1852,8 @@ totem_pl_parser_parse_xml_relaxed (char *contents,
{
xml_node_t* doc, *node;
g_autoptr(GError) error = NULL;
- char *encoding, *new_contents;
+ g_autofree char *encoding = NULL;
+ g_autofree char *new_contents = NULL;
gsize new_size;
xml_parser_t *xml_parser;
@@ -1873,30 +1874,24 @@ totem_pl_parser_parse_xml_relaxed (char *contents,
break;
}
- if (encoding == NULL || g_ascii_strcasecmp (encoding, "UTF-8") == 0) {
- g_free (encoding);
+ if (encoding == NULL || g_ascii_strcasecmp (encoding, "UTF-8") == 0)
return doc;
- }
xml_parser_free_tree (doc);
new_contents = g_convert (contents, size, "UTF-8", encoding, NULL, &new_size, &error);
if (new_contents == NULL) {
g_warning ("Failed to convert XML data to UTF-8: %s", error->message);
- g_free (encoding);
return NULL;
}
- g_free (encoding);
xml_parser = xml_parser_init_r (new_contents, new_size, XML_PARSER_CASE_INSENSITIVE);
if (xml_parser_build_tree_with_options_r (xml_parser, &doc, XML_PARSER_RELAXED |
XML_PARSER_MULTI_TEXT) < 0) {
xml_parser_finalize_r (xml_parser);
- g_free (new_contents);
return NULL;
}
xml_parser_finalize_r (xml_parser);
- g_free (new_contents);
return doc;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]