From: <fr...@us...> - 2011-09-05 12:17:40
|
Revision: 4539 http://fuse-emulator.svn.sourceforge.net/fuse-emulator/?rev=4539&view=rev Author: fredm Date: 2011-09-05 12:17:34 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Remove operations with uninitialised pointers in libspectrum_make_room, at stopping RZX recordings or saving snapshots (part of patch #3404090) (Sergio Baldov?\195?\173). Modified Paths: -------------- trunk/libspectrum/libspectrum.c trunk/libspectrum/make-perl.c trunk/libspectrum/myglib/garray.c Modified: trunk/libspectrum/libspectrum.c =================================================================== --- trunk/libspectrum/libspectrum.c 2011-09-05 12:02:04 UTC (rev 4538) +++ trunk/libspectrum/libspectrum.c 2011-09-05 12:17:34 UTC (rev 4539) @@ -914,16 +914,15 @@ libspectrum_make_room( libspectrum_byte **dest, size_t requested, libspectrum_byte **ptr, size_t *allocated ) { - size_t current_length; + size_t current_length = 0; - current_length = *ptr - *dest; - if( *allocated == 0 ) { (*allocated) = requested; *dest = libspectrum_malloc( requested * sizeof( **dest ) ); } else { + current_length = *ptr - *dest; /* If there's already enough room here, just return */ if( current_length + requested <= (*allocated) ) return; Modified: trunk/libspectrum/make-perl.c =================================================================== --- trunk/libspectrum/make-perl.c 2011-09-05 12:02:04 UTC (rev 4538) +++ trunk/libspectrum/make-perl.c 2011-09-05 12:17:34 UTC (rev 4539) @@ -253,6 +253,7 @@ "WIN32_DLL GArray* g_array_append_vals( GArray *array, gconstpointer data, guint len );\n" "#define g_array_index(a,t,i) (*(((t*)a->data)+i))\n" "WIN32_DLL GArray* g_array_set_size( GArray *array, guint length );\n" +"WIN32_DLL gchar* g_array_free( GArray *array, gboolean free_segment );\n" "\n" ); if( sizeof( void* ) == sizeof( int ) ) { printf( "#define GINT_TO_POINTER(i) ((gpointer) (i))\n" ); Modified: trunk/libspectrum/myglib/garray.c =================================================================== --- trunk/libspectrum/myglib/garray.c 2011-09-05 12:02:04 UTC (rev 4538) +++ trunk/libspectrum/myglib/garray.c 2011-09-05 12:17:34 UTC (rev 4539) @@ -96,4 +96,21 @@ return array; } +gchar* +g_array_free( GArray *array, gboolean free_segment ) +{ + gchar* segment; + + if( free_segment ) { + libspectrum_free( array->data ); + segment = NULL; + } + else + segment = array->data; + + libspectrum_free( array ); + + return segment; +} + #endif /* #ifndef HAVE_LIB_GLIB */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |