When setting a bogus sound in gamedata_read_tbl, don't let piggy_close free it. Fixes freeing of non-malloc'd pointer for PC shareware data

This commit is contained in:
Chris Taylor 2010-12-04 13:44:09 +08:00
parent f0c4d80f48
commit f4ec76d74d
3 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20101204
--------
main/bmread.c, main/piggy.c: When setting a bogus sound in gamedata_read_tbl, don't let piggy_close free it. Fixes freeing of non-malloc'd pointer for PC shareware data
20101203
--------
main/net_udp.c: Made resent_delay for net_udp_noloss_process_queue() a bit longer depending on the player's ping

View file

@ -285,7 +285,9 @@ int ds_load(int skip, char * filename ) {
char rawname[100];
if (skip) {
return piggy_register_sound( &bogus_sound, "bogus", 0 );
// We tell piggy_register_sound it's in the pig file, when in actual fact it's in no file
// This just tells piggy_close not to attempt to free it
return piggy_register_sound( &bogus_sound, "bogus", 1 );
}
removeext( filename, fname );

View file

@ -211,6 +211,8 @@ int piggy_register_sound( digi_sound * snd, char * name, int in_file )
if ( !in_file ) {
SoundOffset[Num_sound_files] = 0;
}
else if (SoundOffset[Num_sound_files] == 0)
SoundOffset[Num_sound_files] = -1; // make sure this sound's data is not individually freed
i = Num_sound_files;