Changeset 4217


Ignore:
Timestamp:
Dec 19, 2007, 12:38:36 PM (14 years ago)
Author:
charles
Message:

(gtk) quick fix for the memory corruption bug reported by werehamster

Location:
trunk/gtk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/stats.c

    r4210 r4217  
    3232
    3333static void
    34 setLabel( GtkWidget * w, char * ownme )
     34setLabel( GtkWidget * w, const char * str )
    3535{
    36     gtk_label_set_text( GTK_LABEL(w), ownme );
    37     g_free( ownme );
     36    gtk_label_set_text( GTK_LABEL(w), str );
    3837}
    3938
     
    4140setLabelFromRatio( GtkWidget * w, double d )
    4241{
    43     char * str = ( (int)d == TR_RATIO_NA )
    44         ? g_strdup_printf( _("None" ) )
    45         : g_strdup_printf( "%.1f%%", d );
    46     setLabel( w, str );
     42    char buf[128];
     43    if( ( (int)d == TR_RATIO_NA ) )
     44        g_strlcpy( buf, _("None"), sizeof(buf) );
     45    else
     46        g_snprintf( buf, sizeof(buf), "%.1f", d );
     47    setLabel( w, buf );
    4748}
    4849
  • trunk/gtk/tr_window.c

    r4210 r4217  
    163163    gtk_widget_set_usize (w, 0u, 6u);
    164164    gtk_box_pack_start( GTK_BOX(vbox), w, FALSE, FALSE, 0 );
    165 
    166165
    167166    /* statusbar */
Note: See TracChangeset for help on using the changeset viewer.