Skip to content

Commit

Permalink
Avoid overflow in ResampleSfx for wavs with >8M samples
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Jul 18, 2024
1 parent e4b2af9 commit cdd2ff0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Quake/snd_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
else
{
// general case
samplefrac = 0;
srcsample = samplefrac = 0;
fracstep = stepscale*256;
for (i = 0; i < outcount; i++)
{
srcsample = samplefrac >> 8;
samplefrac += fracstep;
if (inwidth == 2)
sample = LittleShort ( ((short *)data)[srcsample] );
else
Expand All @@ -79,6 +77,9 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data)
((short *)sc->data)[i] = sample;
else
((signed char *)sc->data)[i] = sample >> 8;
samplefrac += fracstep;
srcsample += samplefrac >> 8;
samplefrac &= 255;
}
}
}
Expand Down

0 comments on commit cdd2ff0

Please sign in to comment.