jaudiolib: don't attempt audio format auto-detection for less than 12 bytes.

git-svn-id: https://svn.eduke32.com/eduke32@4263 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-01-24 21:38:59 +00:00
parent b6e9c0b409
commit 0ab2814f2e

View file

@ -874,8 +874,11 @@ int32_t FX_StartDemandFeedPlayback
} }
static wavedata FX_AutoDetectFormat(const char *ptr) static wavedata FX_AutoDetectFormat(const char *ptr, uint32_t length)
{ {
if (length < 12)
return Unknown;
switch (LITTLE32(*(int32_t *)ptr)) switch (LITTLE32(*(int32_t *)ptr))
{ {
case 'C'+('r'<<8)+('e'<<16)+('a'<<24): // Crea case 'C'+('r'<<8)+('e'<<16)+('a'<<24): // Crea
@ -925,7 +928,7 @@ int32_t FX_PlayLoopedAuto(char *ptr, uint32_t length, int32_t loopstart, int32_t
{ {
int32_t handle = -1; int32_t handle = -1;
switch (FX_AutoDetectFormat(ptr)) switch (FX_AutoDetectFormat(ptr, length))
{ {
case VOC: case VOC:
handle = MV_PlayVOC(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval); handle = MV_PlayVOC(ptr, length, loopstart, loopend, pitchoffset, vol, left, right, priority, callbackval);
@ -973,7 +976,7 @@ int32_t FX_PlayAuto3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitch
{ {
int32_t handle = -1; int32_t handle = -1;
switch (FX_AutoDetectFormat(ptr)) switch (FX_AutoDetectFormat(ptr, length))
{ {
case VOC: case VOC:
handle = MV_PlayVOC3D(ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval); handle = MV_PlayVOC3D(ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval);