changeset 9965:f175970357d1

8240482: Improved WAV file playback Reviewed-by: amenkov, rhalade, mschoene, prr
author serb
date Mon, 23 Mar 2020 19:57:51 -0700
parents b7aa6cda7a03
children e5ffc34ee665
files src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp	Tue Mar 17 13:46:19 2020 -0700
+++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp	Mon Mar 23 19:57:51 2020 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -203,10 +203,14 @@
     // (required only if Write() can override the buffer)
     bool Allocate(int requestedBufferSize, int extraBytes) {
         int fullBufferSize = requestedBufferSize + extraBytes;
-        int powerOfTwo = 1;
+        long powerOfTwo = 1;
         while (powerOfTwo < fullBufferSize) {
             powerOfTwo <<= 1;
         }
+        if (powerOfTwo > INT_MAX || fullBufferSize < 0) {
+            ERROR0("RingBuffer::Allocate: REQUESTED MEMORY SIZE IS TOO BIG\n");
+            return false;
+        }
         pBuffer = (Byte*)malloc(powerOfTwo);
         if (pBuffer == NULL) {
             ERROR0("RingBuffer::Allocate: OUT OF MEMORY\n");