1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-17 14:11:06 +00:00

Fix possible crash on AudioDriver::input_buffer_write

This commit is contained in:
Marcelo Fernandez
2019-03-02 15:01:26 -03:00
parent 90038a4eef
commit f529649cec
2 changed files with 13 additions and 7 deletions

View File

@@ -90,12 +90,16 @@ void AudioDriver::input_buffer_init(int driver_buffer_frames) {
void AudioDriver::input_buffer_write(int32_t sample) {
input_buffer.write[input_position++] = sample;
if ((int)input_position >= input_buffer.size()) {
input_position = 0;
}
if ((int)input_size < input_buffer.size()) {
input_size++;
if ((int)input_position < input_buffer.size()) {
input_buffer.write[input_position++] = sample;
if ((int)input_position >= input_buffer.size()) {
input_position = 0;
}
if ((int)input_size < input_buffer.size()) {
input_size++;
}
} else {
WARN_PRINTS("input_buffer_write: Invalid input_position=" + itos(input_position) + " input_buffer.size()=" + itos(input_buffer.size()));
}
}
@@ -145,6 +149,8 @@ AudioDriver::AudioDriver() {
_last_mix_time = 0;
_mix_amount = 0;
input_position = 0;
input_size = 0;
#ifdef DEBUG_ENABLED
prof_time = 0;