xbadpcm: fix crash on invalid input file
authorAnssi Hannula <anssi@xbmc.org>
Sat, 31 Aug 2013 08:30:32 +0000 (11:30 +0300)
committerAnssi Hannula <anssi@xbmc.org>
Sat, 31 Aug 2013 08:33:21 +0000 (11:33 +0300)
If the sample rate or channel count is zero on a file opened with
ADPCMDll, a division by zero is performed causing XBMC to crash.

Fix that by adding the necessary check.

lib/xbadpcm/ADPCMDll.cpp

index 67e27e5..b0dab89 100644 (file)
@@ -47,6 +47,10 @@ extern "C"
     int     wavsize;
 
     wavsize = mywav_data(info->f, &info->fmt);
+
+    if (info->fmt.dwSamplesPerSec == 0 || info->fmt.wChannels == 0)
+        return -1;
+
     if(wavsize >= 0) {
         if(info->fmt.wFormatTag != 0x0069) {
             fseek(info->f,0,SEEK_SET);