From c5d47660c70125bf3e15c5506acb11981d2c9cb8 Mon Sep 17 00:00:00 2001 From: serb Date: Mon, 23 Mar 2020 19:57:51 -0700 Subject: [PATCH] 8240482: Improved WAV file playback Reviewed-by: amenkov, rhalade, mschoene, prr --- .../com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp index cadbb11bc..608ee13d7 100644 --- a/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp +++ b/src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, 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 @@ -202,10 +202,14 @@ public: // (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"); -- GitLab