Index: src/frames.c
===================================================================
RCS file: /cvs/gnome/metacity/src/frames.c,v
retrieving revision 1.82
diff -u -p -r1.82 frames.c
--- src/frames.c	26 Jun 2005 21:58:37 -0000	1.82
+++ src/frames.c	1 Sep 2005 20:52:48 -0000
@@ -34,6 +34,7 @@
 #endif
 
 #define DEFAULT_INNER_BUTTON_BORDER 3
+#define META_FRAME_MAX_TITLE_LENGTH 512
 
 static void meta_frames_class_init (MetaFramesClass *klass);
 static void meta_frames_init       (MetaFrames      *frames);
@@ -1048,6 +1049,21 @@ meta_frames_queue_draw (MetaFrames *fram
   invalidate_whole_window (frames, frame);
 }
 
+static gchar *
+meta_g_utf8_strndup (const gchar *src,
+                     gsize        n)
+{
+  const gchar *s = src;
+
+  while (n && *s)
+    {
+      s = g_utf8_next_char (s);
+      n--;
+    }
+
+  return g_strndup (src, s - src);
+}
+
 void
 meta_frames_set_title (MetaFrames *frames,
                        Window      xwindow,
@@ -1063,7 +1079,7 @@ meta_frames_set_title (MetaFrames *frame
   g_assert (frame);
   
   g_free (frame->title);
-  frame->title = g_strdup (title);
+  frame->title = meta_g_utf8_strndup (title, META_FRAME_MAX_TITLE_LENGTH);
   
   if (frame->layout)
     {
