Avoid buffer overflow

- Appears to fix a crash on Kindle Fire 1st Gen
This commit is contained in:
Aaron Culliney 2015-10-30 23:14:20 -07:00
parent 84fe0dd479
commit 20f79dc5eb
2 changed files with 8 additions and 1 deletions

View File

@ -417,7 +417,7 @@ static long opensl_createSoundBuffer(const AudioContext_s *audio_context, INOUT
unsigned long bufferSize = opensles_audio_backend.systemSettings.stereoBufferSizeSamples * opensles_audio_backend.systemSettings.bytesPerSample * NUM_CHANNELS;
if (ctx->recycledVoices) {
LOG("Recycling previously SLVoice ...");
LOG("Recycling previous SLVoice ...");
voice = ctx->recycledVoices;
ctx->recycledVoices = voice->next;
uint8_t *prevBuffer = voice->ringBuffer;

View File

@ -307,6 +307,13 @@ static unsigned int _submit_samples_buffer(const unsigned long num_channel_sampl
break;
}
unsigned long maxSpeakerBytes = channelsSampleRateHz * sizeof(int16_t);
if (system_buffer_size > maxSpeakerBytes) {
RELEASE_LOG("AVOIDING BUFOVER...");
system_buffer_size = maxSpeakerBytes;
}
memcpy(system_samples_buffer, &samples_buffer[samples_idx], system_buffer_size);
err = speakerBuffer->Unlock(speakerBuffer, system_buffer_size);