mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Avoid num_samples from becoming negative (#653)
For Soundfonts bigger 2GiB, num_samples becomes negative. When being passed to safe_fread() it's promoted to long long and when being passed to fread(), it's cast to size_t. Works fine in twos-complement, but still is not nice.
This commit is contained in:
parent
0354196e43
commit
e16ca05a58
1 changed files with 5 additions and 3 deletions
|
@ -2379,9 +2379,11 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en
|
|||
{
|
||||
short *loaded_data = NULL;
|
||||
char *loaded_data24 = NULL;
|
||||
unsigned int num_samples;
|
||||
|
||||
int num_samples = (end + 1) - start;
|
||||
fluid_return_val_if_fail(num_samples > 0, -1);
|
||||
fluid_return_val_if_fail((end + 1) > start , -1);
|
||||
|
||||
num_samples = (end + 1) - start;
|
||||
|
||||
if((start * sizeof(short) > sf->samplesize) || (end * sizeof(short) > sf->samplesize))
|
||||
{
|
||||
|
@ -2413,7 +2415,7 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en
|
|||
/* If this machine is big endian, byte swap the 16 bit samples */
|
||||
if(FLUID_IS_BIG_ENDIAN)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < num_samples; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue