changeset 77848:284e73632cf1

(x_set_name_internal): Save encoded name before x_encode_text in case string data is relocated.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 01 Jun 2007 03:58:05 +0000
parents 9fd1cc764768
children f68ce6aa4bd1
files src/xfns.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfns.c	Fri Jun 01 03:57:53 2007 +0000
+++ b/src/xfns.c	Fri Jun 01 03:58:05 2007 +0000
@@ -1605,6 +1605,16 @@
 	int bytes, stringp;
         int do_free_icon_value = 0, do_free_text_value = 0;
 	Lisp_Object coding_system;
+#ifdef USE_GTK
+	Lisp_Object encoded_name;
+	struct gcpro gcpro1;
+
+	/* As ENCODE_UTF_8 may cause GC and relocation of string data,
+	   we use it before x_encode_text that may return string data.  */
+	GCPRO1 (name);
+	encoded_name = ENCODE_UTF_8 (name);
+	UNGCPRO;
+#endif
 
 	coding_system = Qcompound_text;
 	/* Note: Encoding strategy
@@ -1645,7 +1655,7 @@
 
 #ifdef USE_GTK
         gtk_window_set_title (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
-                              (char *) SDATA (ENCODE_UTF_8 (name)));
+                              (char *) SDATA (encoded_name));
 #else /* not USE_GTK */
 	XSetWMName (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), &text);
 #endif /* not USE_GTK */