From: <fr...@us...> - 2012-11-07 11:58:33
|
Revision: 4758 http://fuse-emulator.svn.sourceforge.net/fuse-emulator/?rev=4758&view=rev Author: fredm Date: 2012-11-07 11:58:26 +0000 (Wed, 07 Nov 2012) Log Message: ----------- Fix potential calls to memcpy with a null pointer argument (thanks, clang 4.1) (Fred). Modified Paths: -------------- trunk/libspectrum/hacking/ChangeLog trunk/libspectrum/szx.c Modified: trunk/libspectrum/hacking/ChangeLog =================================================================== --- trunk/libspectrum/hacking/ChangeLog 2012-11-07 11:14:48 UTC (rev 4757) +++ trunk/libspectrum/hacking/ChangeLog 2012-11-07 11:58:26 UTC (rev 4758) @@ -896,3 +896,5 @@ using an old pkg-config/autoconf (bug #3579244) (Sergio). 20121107 Makefile.am: fix the build when source and build trees are different (VPATH) (bug #3584527) (Sergio). +20120203 szx.c: fix potential calls to memcpy with a null pointer argument + (thanks, clang 4.1) (Fred). Modified: trunk/libspectrum/szx.c =================================================================== --- trunk/libspectrum/szx.c 2012-11-07 11:14:48 UTC (rev 4757) +++ trunk/libspectrum/szx.c 2012-11-07 11:58:26 UTC (rev 4758) @@ -3096,7 +3096,7 @@ *(*ptr)++ = libspectrum_snap_beta_data ( snap ); *(*ptr)++ = libspectrum_snap_beta_status( snap ); - if( libspectrum_snap_beta_custom_rom( snap ) ) { + if( libspectrum_snap_beta_custom_rom( snap ) && rom_data ) { memcpy( *ptr, rom_data, beta_rom_length ); *ptr += beta_rom_length; } @@ -3179,7 +3179,7 @@ *ptr += sizeof(libspectrum_dword) * 8; /* Skip 'reserved' data */ libspectrum_write_word( ptr, uncompressed_rom_length ); - if( libspectrum_snap_interface1_custom_rom( snap ) ) { + if( libspectrum_snap_interface1_custom_rom( snap ) && disk_rom_length ) { memcpy( *ptr, rom_data, disk_rom_length ); *ptr += disk_rom_length; } @@ -3545,6 +3545,11 @@ int use_compression = 0; eprom_data = libspectrum_snap_divide_eprom( snap, 0 ); + if( !eprom_data ) { + libspectrum_print_error( LIBSPECTRUM_ERROR_LOGIC, + "DivIDE EPROM data is missing" ); + return LIBSPECTRUM_ERROR_LOGIC; + } uncompressed_eprom_length = divide_eprom_length = 0x2000; #ifdef HAVE_ZLIB_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |