From 2080f6d2bd18e879003a362f9a01ecf40800a6af Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Tue, 13 Jul 1999 18:27:05 +0000 Subject: [PATCH] 1999-07-13 Miguel de Icaza * gnome-file-property-dialog.c (perm_group_new): the return values from the group functions in libc return pointers to static buffers in the library. Duplicate all return values and free them at the end. --- gnome/ChangeLog | 7 +++++++ gnome/gnome-file-property-dialog.c | 23 +++++++++-------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gnome/ChangeLog b/gnome/ChangeLog index c66c019a2..3728170fe 100644 --- a/gnome/ChangeLog +++ b/gnome/ChangeLog @@ -1,3 +1,10 @@ +1999-07-13 Miguel de Icaza + + * gnome-file-property-dialog.c (perm_group_new): the return values + from the group functions in libc return pointers to static buffers + in the library. Duplicate all return values and free them at the + end. + 1999-07-12 Miguel de Icaza * gdesktop.c (icon_drag_data_received): Use desktop directory here diff --git a/gnome/gnome-file-property-dialog.c b/gnome/gnome-file-property-dialog.c index 3fec5fd40..04511a749 100644 --- a/gnome/gnome-file-property-dialog.c +++ b/gnome/gnome-file-property-dialog.c @@ -838,28 +838,22 @@ perm_group_new (GnomeFilePropertyDialog *fp_dlg) if (grp->gr_name) fp_dlg->group_name = g_strdup (grp->gr_name); else { - sprintf (grpnum, "%d", (int) grp->gr_gid); - fp_dlg->group_name = g_strdup (grpnum); + fp_dlg->group_name = g_strdup_printf ("%d", (int) grp->gr_gid); } } else { - sprintf (grpnum, "%d", (int) fp_dlg->st.st_gid); - fp_dlg->group_name = g_strdup (grpnum); + fp_dlg->group_name = g_strdup_printf ("%d", (int) fp_dlg->st.st_gid); } /* we change this, b/c we are able to set the egid, if we aren't in the group already */ grp = getgrgid (getegid()); if (grp) { if (grp->gr_name) - grpname = grp->gr_name; - else { - sprintf (grpnum, "%d", (int) grp->gr_gid); - grpname = grpnum; - } - } else { - sprintf (grpnum, "%d", (int) fp_dlg->st.st_gid); - grpname = grpnum; - } - + grpname = g_strdup (grp->gr_name); + else + grpname = g_strdup_printf ("%d", (int) grp->gr_gid); + } else + grpname = g_strdup_printf ("%d", (int) fp_dlg->st.st_gid); + if (fp_dlg->euid != 0) gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (gentry)->entry), FALSE); for (setgrent (); (grp = getgrent ()) != NULL;) { @@ -902,6 +896,7 @@ perm_group_new (GnomeFilePropertyDialog *fp_dlg) grp = getgrgid (fp_dlg->st.st_gid); gtk_entry_set_text (GTK_ENTRY (gentry), grp->gr_name); } + g_free (grpname); return gentry; }