Re: [patch] serious problem in pango_layout_set_text()



Hi,

Owen Taylor <otaylor redhat com> writes:

> So, making the API return a value here is wrong. However, I wouldn't
> object to a patch that didn't free the old value of layout->text
> until after validating the new string ... if it's easy, we might
> as well try to prevent a crash.

can I commit the following change then?


Salut, Sven

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/pango/ChangeLog,v
retrieving revision 1.300
diff -u -r1.300 ChangeLog
--- ChangeLog	2001/08/16 04:29:41	1.300
+++ ChangeLog	2001/08/22 23:21:59
@@ -1,7 +1,13 @@
+2001-08-23  Sven Neumann  <sven gimp org>
+
+	* pango/pango-layout.c (pango_layout_set_text): if bailing out because
+	the function was being passed an invalid UTF-8 string, don't free the 
+	old text of the PangoLayout to prevent a crash on the next call.
+	
 2001-08-16  Alexander Larsson  <alexl redhat com>
 
-	* pango/pangowin32.c: 
-	Fully convert the truetype unicode table to host endianness when reading it.
+	* pango/pangowin32.c: Fully convert the truetype unicode table to 
+	host endianness when reading it.
 	Add a cache of one to find_segment since it showed up on a profile.
 
 2001-08-15  Jens Finke <jens gnome org>
Index: docs/tmpl/layout.sgml
===================================================================
RCS file: /cvs/gnome/pango/docs/tmpl/layout.sgml,v
retrieving revision 1.17
diff -u -r1.17 layout.sgml
--- docs/tmpl/layout.sgml	2001/06/08 16:02:58	1.17
+++ docs/tmpl/layout.sgml	2001/08/22 23:21:59
@@ -97,6 +97,8 @@
 @layout: 
 @text: 
 @length: 
+<!-- # Unused Parameters # -->
+ Returns: 
 
 
 <!-- ##### FUNCTION pango_layout_get_text ##### -->
Index: pango/pango-layout.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-layout.c,v
retrieving revision 1.68
diff -u -r1.68 pango-layout.c
--- pango/pango-layout.c	2001/08/09 07:29:41	1.68
+++ pango/pango-layout.c	2001/08/22 23:21:59
@@ -723,11 +723,11 @@
   g_return_if_fail (layout != NULL);
   g_return_if_fail (length == 0 || text != NULL);
   
-  if (layout->text)
-    g_free (layout->text);
-
   if (length == 0)
     {
+      if (layout->text)
+        g_free (layout->text);
+
       layout->text = g_strdup ("");
       layout->n_chars = 0;
     }
@@ -755,6 +755,9 @@
 
       length = p - text;
       
+      if (layout->text)
+        g_free (layout->text);
+
       /* NULL-terminate the text for convenience.
        */
       




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