< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java

Print this page

        

@@ -250,8 +250,12 @@
      * @param sampleSizeInBits the size of a single sample in bits
      * @param channels the number of channels
      * @return the size of a PCM frame in bytes.
      */
     static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) {
-        return ((sampleSizeInBits + 7) / 8) * channels;
+        try {
+            return Math.multiplyExact((sampleSizeInBits + 7) / 8, channels);
+        } catch (final ArithmeticException ignored) {
+            return 0;
+        }
     }
 }
< prev index next >