Fix a VGM crash when loading unsupported files.
This commit is contained in:
parent
b262dfa508
commit
5006d05222
2 changed files with 7 additions and 1 deletions
|
@ -29,13 +29,14 @@ Vgm_Emu::Vgm_Emu()
|
||||||
set_type( gme_vgm_type );
|
set_type( gme_vgm_type );
|
||||||
set_max_initial_silence( 1 );
|
set_max_initial_silence( 1 );
|
||||||
set_silence_lookahead( 1 ); // tracks should already be trimmed
|
set_silence_lookahead( 1 ); // tracks should already be trimmed
|
||||||
|
voice_names_assigned_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vgm_Emu::~Vgm_Emu()
|
Vgm_Emu::~Vgm_Emu()
|
||||||
{
|
{
|
||||||
// XXX ugly use of deprecated functions to free allocated voice names
|
// XXX ugly use of deprecated functions to free allocated voice names
|
||||||
const char ** voice_names_ = voice_names();
|
const char ** voice_names_ = voice_names();
|
||||||
if (voice_names_)
|
if (voice_names_assigned_ && voice_names_)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 32; ++i)
|
for (int i = 0; i < 32; ++i)
|
||||||
{
|
{
|
||||||
|
@ -512,7 +513,10 @@ blargg_err_t Vgm_Emu::load_mem_( const byte* in, int file_size )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i == voice_count)
|
if (i == voice_count)
|
||||||
|
{
|
||||||
set_voice_names(voice_names);
|
set_voice_names(voice_names);
|
||||||
|
voice_names_assigned_ = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < voice_count; i++)
|
for (i = 0; i < voice_count; i++)
|
||||||
|
|
|
@ -54,6 +54,8 @@ private:
|
||||||
blargg_vector<byte> data;
|
blargg_vector<byte> data;
|
||||||
track_info_t metadata;
|
track_info_t metadata;
|
||||||
track_info_t metadata_j;
|
track_info_t metadata_j;
|
||||||
|
|
||||||
|
bool voice_names_assigned_;
|
||||||
|
|
||||||
void check_end();
|
void check_end();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue