From 0ab2814f2eb6c36e2e91c46890a333a9cade0eb2 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Fri, 24 Jan 2014 21:38:59 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/jaudiolib/src/fx_man.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/source/jaudiolib/src/fx_man.c b/polymer/eduke32/source/jaudiolib/src/fx_man.c index e8032e2d3..8f62b384a 100644 --- a/polymer/eduke32/source/jaudiolib/src/fx_man.c +++ b/polymer/eduke32/source/jaudiolib/src/fx_man.c @@ -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)) { 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; - switch (FX_AutoDetectFormat(ptr)) + switch (FX_AutoDetectFormat(ptr, length)) { case VOC: 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; - switch (FX_AutoDetectFormat(ptr)) + switch (FX_AutoDetectFormat(ptr, length)) { case VOC: handle = MV_PlayVOC3D(ptr, length, loophow, pitchoffset, angle, distance, priority, callbackval);