We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4604 - Divide by zero crash in voc_get_block()
Summary: Divide by zero crash in voc_get_block()
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Assignee: Ozkan Sezer
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-21 08:07 UTC by Mark Terbeck
Modified: 2020-06-26 22:01 UTC (History)
1 user (show)

See Also:


Attachments
VOC file that triggers the bug. (4.06 KB, application/octet-stream)
2019-04-21 12:19 UTC, Mark Terbeck
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Terbeck 2019-04-21 08:07:07 UTC
The crash happens within the a extended information block (case VOC_EXTENDED) handling, due to the fact that number of channels is never set for mono samples. So when the sample rate is calculated the divisor is 0.

To fix this simply add a else clause - which sets the number of channels to 1 - to the if() which sets the number of channels to 2 for stereo.

This bug is present in SDL_mixer 1.2.12, SDL_mixer 2.0.4 and SDL_sound.
Comment 1 Mark Terbeck 2019-04-21 12:19:24 UTC
Created attachment 3761 [details]
VOC file that triggers the bug.
Comment 2 Ozkan Sezer 2020-06-26 21:52:29 UTC
Should be fixed in both SDL_mixer-1.2 and SDL2_mixer:
http://hg.libsdl.org/SDL_mixer/rev/33b9d022472d
http://hg.libsdl.org/SDL_mixer/rev/037c22bc945d
Comment 3 Ozkan Sezer 2020-06-26 22:01:07 UTC
SDL_sound version of fixes are in my fork of SDL_sound at github:
https://github.com/sezero/SDL_sound/commit/a343b5ac38cbace0c129c51023f6a9a4c464eb30
https://github.com/sezero/SDL_sound/commit/815ad2191a5b67795735000af2177446f06bbb60

(icculus doesn't seem to work on SDL_sound for quite some time..)