[gnome-games] Fix *** glibc detected *** gtali: free(): invalid pointer.



commit 53ae87499eb1d839b58c1f148b14986f2e53b184
Author: Romain Perier <mrpouet gentoo org>
Date:   Tue Jun 8 16:02:35 2010 +1000

    Fix *** glibc detected *** gtali: free(): invalid pointer.
    
    This error happened in case where default players names was used,
    in yahtzee.c "Human" string is just marked by N_() to be translated later (runtime),
    but not really translated (so "Human" is assigned to DefaultPlayerNames[0]).
    In players[0].name the translated string is assigned ie _("Human").
    This implies that "if (players[0].name != DefaultPlayerNames[0])"
    is always true because _("Human") hasn't the same address as "Human".
    And we can't free a string allocated in .ro_data section.

 gtali/setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/gtali/setup.c b/gtali/setup.c
index b985f22..ebc5190 100644
--- a/gtali/setup.c
+++ b/gtali/setup.c
@@ -149,7 +149,7 @@ do_setup (GtkWidget * widget, gpointer data)
   DisplayComputerThoughts = tmpDisplayComputerThoughts;
 
   for (i = 0; i < MAX_NUMBER_OF_PLAYERS; i++) {
-    if (players[i].name != DefaultPlayerNames[i])
+    if (players[i].name != _(DefaultPlayerNames[i]))
       g_free (players[i].name);
     players[i].name =
       g_strdup (gtk_entry_get_text (GTK_ENTRY (PlayerNames[i])));



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