Skip to content

Commit 43382a1

Browse files
committed
Disallow negative frames/ms
1 parent 875958f commit 43382a1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/SDL_mixer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,8 @@ bool MIX_SetTrackPlaybackPosition(MIX_Track *track, Sint64 frames)
17741774
{
17751775
if (!CheckTrackParam(track)) {
17761776
return false;
1777+
} else if (frames < 0) {
1778+
return SDL_InvalidParamError("frames");
17771779
}
17781780

17791781
bool retval = true;
@@ -1864,6 +1866,8 @@ Sint64 MIX_MSToFrames(int sample_rate, Sint64 ms)
18641866
{
18651867
if (sample_rate <= 0) {
18661868
return 0;
1869+
} else if (ms < 0) {
1870+
return 0;
18671871
}
18681872
return (Sint64) ((((double) ms) / 1000.0) * ((double) sample_rate));
18691873
}
@@ -1872,6 +1876,8 @@ Sint64 MIX_FramesToMS(int sample_rate, Sint64 frames)
18721876
{
18731877
if (sample_rate <= 0) {
18741878
return 0;
1879+
} else if (frames < 0) {
1880+
return 0;
18751881
}
18761882
return (Sint64) ((((double) frames) / ((double) sample_rate)) * 1000.0);
18771883
}

0 commit comments

Comments
 (0)