Skip to content

Commit

Permalink
fix WaveCrop(): update wave->frameCount (#4003)
Browse files Browse the repository at this point in the history
also allow `finalFrame = wave->frameCount' as the range of frames does
not include it.

Co-authored-by: Listeria monocytogenes <[email protected]>
  • Loading branch information
ListeriaM and Listeria monocytogenes authored May 24, 2024
1 parent d9c5066 commit b429dbd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/raudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,7 @@ Wave WaveCopy(Wave wave)
// NOTE: Security check in case of out-of-range
void WaveCrop(Wave *wave, int initFrame, int finalFrame)
{
if ((initFrame >= 0) && (initFrame < finalFrame) && ((unsigned int)finalFrame < wave->frameCount))
if ((initFrame >= 0) && (initFrame < finalFrame) && ((unsigned int)finalFrame <= wave->frameCount))
{
int frameCount = finalFrame - initFrame;

Expand All @@ -1288,6 +1288,7 @@ void WaveCrop(Wave *wave, int initFrame, int finalFrame)

RL_FREE(wave->data);
wave->data = data;
wave->frameCount = (unsigned int)frameCount;
}
else TRACELOG(LOG_WARNING, "WAVE: Crop range out of bounds");
}
Expand Down

0 comments on commit b429dbd

Please sign in to comment.