Re: [PATCH] Segfault fix in pango



On 16 Apr 2001 11:57:38 -0400, Owen Taylor wrote:
> 
> This looks fine as far as it goes but glancing at the code there seems
> to be various places where md->text is appended to without checking to
> see if it is NULL.
> 
> It wouldn't be hard to fix these up, but talking it over
> with Havoc, we don't think that people will really use
> it with text == NULL. So, the better course (reduce complexity)
> is to simply always compute md->text, remove the existing
> if (md->text) checks and discard the result if text == NULL.
> 
> Feel free to commit a patch to that effect.
> 
> Regards,
>                                         Owen
> 

I've committed the attached patch. Let me know if there's something
wrong with it.

//andersca
andersca gnu org
? confdefs.h
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/pango/ChangeLog,v
retrieving revision 1.245
diff -u -r1.245 ChangeLog
--- ChangeLog	2001/04/17 22:39:29	1.245
+++ ChangeLog	2001/04/20 10:01:28
@@ -1,3 +1,8 @@
+2001-04-20  Anders Carlsson  <andersca codefactory se>
+
+	* pango/pango-markup.c (pango_parse_markup): Discard the parsed text if
+	the input variable text is NULL. This fixes a segfault.
+
 Tue Apr 17 15:44:53 2001  Owen Taylor  <otaylor redhat com>
 
 	* Release 0.15
Index: pango/pango-markup.c
===================================================================
RCS file: /cvs/gnome/pango/pango/pango-markup.c,v
retrieving revision 1.4
diff -u -r1.4 pango-markup.c
--- pango/pango-markup.c	2000/11/30 21:04:52	1.4
+++ pango/pango-markup.c	2001/04/20 10:01:28
@@ -601,8 +601,7 @@
   if (attr_list)
     md->attr_list = pango_attr_list_new ();
 
-  if (text)
-    md->text = g_string_new ("");
+  md->text = g_string_new ("");
   
   if (accel_char)
     *accel_char = 0;
@@ -678,7 +677,9 @@
 
   if (text)
     *text = g_string_free (md->text, FALSE);
-
+  else
+    g_string_free (md->text, TRUE);
+  
   if (accel_char)
     *accel_char = md->accel_char;
   


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