[paplayer] Prevent possible division by zero in MP3Codec.
authorace20022 <ace20022@ymail.com>
Fri, 7 Mar 2014 20:20:25 +0000 (21:20 +0100)
committerace20022 <ace20022@ymail.com>
Fri, 7 Mar 2014 20:24:49 +0000 (21:24 +0100)
xbmc/cores/paplayer/MP3codec.cpp

index 7db7a15..a6f663a 100644 (file)
@@ -886,13 +886,14 @@ int MP3Codec::ReadDuration()
 
       double tpfbs[] = { 0, 384.0f, 1152.0f, 1152.0f };
       frequency = freqtab[version][freqindex];
-      tpf = tpfbs[layer] / (double) frequency;
-      if (version == MPEG_VERSION2_5 || version == MPEG_VERSION2)
-        tpf /= 2;
 
       if (frequency == 0)
         return 0;
 
+      tpf = tpfbs[layer] / (double) frequency;
+      if (version == MPEG_VERSION2_5 || version == MPEG_VERSION2)
+        tpf /= 2;
+
       /* Channel mode (stereo/mono) */
       int chmode = (mpegheader & 0xc0) >> 6;
       /* calculate position of Xing VBR header */