packages: xsensors/xsensors-cleanup-allocs.patch (NEW)=?UTF-8?Q?=20?=- new - taken from d...

blekot blekot at pld-linux.org
Sun May 27 22:38:10 CEST 2012


Author: blekot                       Date: Sun May 27 20:38:10 2012 GMT
Module: packages                      Tag: HEAD
---- Log message:
- new
- taken from debian
- Fix memory allocation and freeing in add_sensor_tab

---- Files affected:
packages/xsensors:
   xsensors-cleanup-allocs.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/xsensors/xsensors-cleanup-allocs.patch
diff -u /dev/null packages/xsensors/xsensors-cleanup-allocs.patch:1.1
--- /dev/null	Sun May 27 22:38:10 2012
+++ packages/xsensors/xsensors-cleanup-allocs.patch	Sun May 27 22:38:05 2012
@@ -0,0 +1,47 @@
+--- a/src/gui.c
++++ b/src/gui.c
+@@ -358,19 +358,20 @@
+             feattext = sensors_get_label( name, feature );
+ 	    
+             if ( feattext != NULL ) {
++                /* We need a temporary variable in case realloc fails */
++                char *new_feattext;
+ #ifdef DEBUG_XSENSORS
+                 printf( "Adding feature %d, %s.\n", i, feattext );
+ #endif
+-                if ( ( feattext = realloc( feattext, 
++                if ( ( new_feattext = realloc( feattext,
+                                 ( strlen( feattext ) + 2 ) * 
+                                 sizeof( char ) ) ) == NULL ) {
+                     fprintf( stderr, "realloc failed in add_sensor_tab()!\n" );
++                    free( feattext );
+                     return NULL;
+                 }
+-                if ( strcat( feattext, ":" ) == NULL ) {
+-                    fprintf( stderr, "strcat failed in add_sensor_tab()!\n" );
+-                    return NULL;
+-                }
++                feattext = new_feattext;
++                strcat( feattext, ":" );
+                 
+                 gtk_frame_set_label( GTK_FRAME (featframe), feattext );
+ 
+@@ -408,8 +409,7 @@
+             gtk_widget_show( innerbox );
+             gtk_widget_show( darea );
+             gtk_widget_show( featpbar );
+-            g_free( feattext );
+-            feattext = NULL;
++            free( feattext );
+     }
+ 
+     if ( usedvolt > 0 ) {
+@@ -430,8 +430,6 @@
+         gtk_widget_show( fanlabel );
+     }
+ 
+-    g_free( feattext );
+-
+     return head;
+ }
+ 
================================================================


More information about the pld-cvs-commit mailing list