vte r2351 - in trunk: . src



Author: behdad
Date: Wed Dec 17 08:26:19 2008
New Revision: 2351
URL: http://svn.gnome.org/viewvc/vte?rev=2351&view=rev

Log:
2008-12-17  Behdad Esfahbod  <behdad gnome org>

        Bug 149631 â gnome-terminal doesn't combine combining chars in utf8

        * src/vteunistr.c:
        Limit to 9 combining marks per unistr, and a total of 100,000 unistrs.
        All to prevent OOM.



Modified:
   trunk/ChangeLog
   trunk/src/vteunistr.c

Modified: trunk/src/vteunistr.c
==============================================================================
--- trunk/src/vteunistr.c	(original)
+++ trunk/src/vteunistr.c	Wed Dec 17 08:26:19 2008
@@ -77,6 +77,8 @@
 
 #define VTE_UNISTR_START 0x80000000
 
+static int _vte_unistr_strlen (vteunistr s);
+
 static vteunistr unistr_next = VTE_UNISTR_START + 1;
 
 struct VteUnistrDecomp {
@@ -125,6 +127,10 @@
 	}
 
 	if (G_UNLIKELY (!ret)) {
+		/* sanity check to avoid OOM */
+		if (G_UNLIKELY (_vte_unistr_strlen (s) > 10 || unistr_next - VTE_UNISTR_START > 100000))
+			return s;
+
 		ret = unistr_next++;
 		g_array_append_val (unistr_decomp, decomp);
 		g_hash_table_insert (unistr_comp,
@@ -157,8 +163,7 @@
 	g_string_append_unichar (gs, (gunichar) s);
 }
 
-#if 0 /* unused */
-int
+static int
 _vte_unistr_strlen (vteunistr s)
 {
 	int len = 1;
@@ -169,4 +174,3 @@
 	}
 	return len;
 }
-#endif



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