# HG changeset patch # User serb # Date 1585018671 25200 # Node ID f175970357d18462e6756505618f2614fc3de6c5 # Parent b7aa6cda7a037d8234e18e8d3ff9086f1d9864ee 8240482: Improved WAV file playback Reviewed-by: amenkov, rhalade, mschoene, prr diff -r b7aa6cda7a03 -r f175970357d1 src/macosx/native/com/sun/media/sound/PLATFORM_API_MacOSX_PCM.cpp --- 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");