From f4b7fda32c476d6b2b5c94d175448f912746e8db Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@gnu.org>
Date: Tue, 11 Sep 2007 03:12:34 +0000
Subject: [PATCH] (psppire_variable_sheet_create): Use xstrdup to save string
 returned by bind_textdomain_codeset.  Otherwise it can get freed by a
 subsequent call.  Patch #6193.  Reviewed by John Darrington.

---
 src/ui/gui/ChangeLog   | 7 +++++++
 src/ui/gui/var-sheet.c | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/ui/gui/ChangeLog b/src/ui/gui/ChangeLog
index 6238e0f7c7..6c36b520ae 100644
--- a/src/ui/gui/ChangeLog
+++ b/src/ui/gui/ChangeLog
@@ -1,3 +1,10 @@
+2007-09-10  Ben Pfaff  <blp@gnu.org>
+
+	* var-sheet.c (psppire_variable_sheet_create): Use xstrdup to save
+	string returned by bind_textdomain_codeset.  Otherwise it can get
+	freed by a subsequent call.  Patch #6193.  Reviewed by John
+	Darrington.
+
 2007-09-06  John Darrington <john@darrington.wattle.id.au>
 	
 	* helper.c helper.h (execute_syntax): changed return type to 
diff --git a/src/ui/gui/var-sheet.c b/src/ui/gui/var-sheet.c
index b57cdb576e..97ab89cb35 100644
--- a/src/ui/gui/var-sheet.c
+++ b/src/ui/gui/var-sheet.c
@@ -38,6 +38,7 @@
 #include <gtksheet/gsheet-uniform-row.h>
 
 #include "localcharset.h"
+#include "xalloc.h"
 #include "psppire-var-store.h"
 #include "helper.h"
 #include "psppire-dict.h"
@@ -455,7 +456,7 @@ psppire_variable_sheet_create (gchar *widget_name,
 
   /* Since this happens inside glade_xml_new, we must prevent strings from
    * being re-encoded twice */
-  codeset = bind_textdomain_codeset (PACKAGE, 0);
+  codeset = xstrdup (bind_textdomain_codeset (PACKAGE, 0));
   bind_textdomain_codeset (PACKAGE, locale_charset ());
 
   for (i = 0 ; i < n_COLS ; ++i )
@@ -468,6 +469,7 @@ psppire_variable_sheet_create (gchar *widget_name,
     }
 
   bind_textdomain_codeset (PACKAGE, codeset);
+  free (codeset);
 
   gtk_widget_show (sheet);
 
-- 
2.30.2