From bac4df147de363a0774548acd63d367a09ab50d3 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 20 Sep 2012 22:40:55 +0200 Subject: some memleak fixes (Bug #1043571) (bzr r11686) --- src/style.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/style.cpp') diff --git a/src/style.cpp b/src/style.cpp index 2facc86d8..616474298 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -3890,10 +3890,9 @@ sp_style_write_istring(gchar *p, gint const len, gchar const *const key, if (val->inherit) { res = g_snprintf(p, len, "%s:inherit;", key); } else { - gchar *val_quoted = css2_escape_quote(val->value); - if (val_quoted) { - res = g_snprintf(p, len, "%s:%s;", key, val_quoted); - g_free (val_quoted); + Glib::ustring val_quoted = css2_escape_quote(val->value); + if (~val_quoted.empty()) { + res = g_snprintf(p, len, "%s:%s;", key, val_quoted.c_str()); } } } @@ -4710,8 +4709,7 @@ attribute_unquote(gchar const *val) /** * Quote and/or escape string for writing to CSS (style=). Returned value must be g_free'd. */ -gchar * -css2_escape_quote(gchar const *val) { +Glib::ustring css2_escape_quote(gchar const *val) { Glib::ustring t; bool quote = false; @@ -4755,7 +4753,7 @@ css2_escape_quote(gchar const *val) { t.push_back('\''); } - return (t.empty() ? NULL : g_strdup (t.c_str())); + return t; } /* -- cgit v1.2.3