mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-12-02 17:12:15 +00:00
Fix preset generator validity checks
The previous implementation used 0 as end-of-list sentinel value. But 0 is also the id of the first generator in the invalid_preset_gen list. This effectively prevented checks for invalid preset generators. Also contains some code cleanup to make the check for invalid instrument generators similar to invalid preset generators. Fixes #821
This commit is contained in:
parent
259aecedf2
commit
c4d38a7125
1 changed files with 14 additions and 10 deletions
|
@ -187,7 +187,6 @@ static const unsigned short invalid_inst_gen[] =
|
|||
Gen_Reserved1,
|
||||
Gen_Reserved2,
|
||||
Gen_Reserved3,
|
||||
0
|
||||
};
|
||||
|
||||
static const unsigned short invalid_preset_gen[] =
|
||||
|
@ -205,7 +204,6 @@ static const unsigned short invalid_preset_gen[] =
|
|||
Gen_SampleModes,
|
||||
Gen_ExclusiveClass,
|
||||
Gen_OverrideRootKey,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
|
@ -2370,37 +2368,43 @@ static fluid_list_t *find_gen_by_id(int gen, fluid_list_t *genlist)
|
|||
/* check validity of instrument generator */
|
||||
static int valid_inst_genid(unsigned short genid)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i;
|
||||
|
||||
if(genid >= Gen_Last)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while(invalid_inst_gen[i] && invalid_inst_gen[i] != genid)
|
||||
for(i = 0; i < FLUID_N_ELEMENTS(invalid_inst_gen); i++)
|
||||
{
|
||||
i++;
|
||||
if (invalid_inst_gen[i] == genid)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (invalid_inst_gen[i] == 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* check validity of preset generator */
|
||||
static int valid_preset_genid(unsigned short genid)
|
||||
{
|
||||
int i = 0;
|
||||
size_t i;
|
||||
|
||||
if(!valid_inst_genid(genid))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while(invalid_preset_gen[i] && invalid_preset_gen[i] != genid)
|
||||
for(i = 0; i < FLUID_N_ELEMENTS(invalid_preset_gen); i++)
|
||||
{
|
||||
i++;
|
||||
if (invalid_preset_gen[i] == genid)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return (invalid_preset_gen[i] == 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue