[libcroco] cr-string: Prevent memory leak



commit 73b04a6ced42bc79107cbb3f23bf53afc4945d06
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Jun 24 15:46:24 2012 -0400

    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

 src/cr-string.c |    8 ++++----
 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 ;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]