summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2012-06-24 15:46:24 -0400
committerJasper St. Pierre <jstpierre@mecheye.net>2012-06-24 16:47:08 -0400
commit73b04a6ced42bc79107cbb3f23bf53afc4945d06 (patch)
tree4f70d23310a8a2fdfb01ec5f66bc20867f217546
parentecb765ad60974742d8e435a48b34fb043194d1ef (diff)
downloadlibcroco-73b04a6ced42bc79107cbb3f23bf53afc4945d06.tar.gz
cr-string: Prevent memory leak
Instead of leaking the existing GString, truncate and append to it instead. https://bugzilla.gnome.org/show_bug.cgi?id=678736
-rw-r--r--src/cr-string.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cr-string.c b/src/cr-string.c
index 633fcab..1b10bb2 100644
--- a/src/cr-string.c
+++ b/src/cr-string.c
@@ -82,10 +82,10 @@ cr_string_new_from_gstring (GString const *a_string)
return NULL ;
}
if (a_string) {
- result->stryng = g_string_new_len
- (a_string->str, a_string->len) ;
- } else {
- result->stryng = g_string_new (NULL) ;
+ g_string_append_len (result->stryng,
+ a_string->str,
+ a_string->len);
+
}
return result ;
}