diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2013-03-13 19:21:58 -0400 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-15 11:53:16 -0700 |
commit | 2babbee09096ef79015442d4680be440a170649d (patch) | |
tree | 64cd288f7b8940dfa14903ab5ffdb0d931fc3b3b /src/library_openal.js | |
parent | 77cdcddb02891426c3b972fe83c013677f957ead (diff) |
Fix bounds checking for buffers
Diffstat (limited to 'src/library_openal.js')
-rw-r--r-- | src/library_openal.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/library_openal.js b/src/library_openal.js index 7665c23f..b9391e22 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -186,11 +186,11 @@ var LibraryOpenAL = { } for (var i = 0; i < count; ++i) { var buffer = {{{ makeGetValue('buffers', 'i', 'i32') }}}; - if (buffer >= AL.currentContext.buf.length) { + if (buffer > AL.currentContext.buf.length) { console.error("alSourceQueueBuffers called with an invalid buffer"); return; } - AL.currentCOntext.src[source].src.buffer = AL.currentContext.buf[buffer].buf; + AL.currentCOntext.src[source].src.buffer = AL.currentContext.buf[buffer - 1].buf; } }, @@ -210,7 +210,7 @@ var LibraryOpenAL = { console.error("alBufferData called without a valid context"); return; } - if (buffer >= AL.currentContext.buf.length) { + if (buffer > AL.currentContext.buf.length) { console.error("alBufferData called with an invalid buffer"); return; } @@ -232,10 +232,10 @@ var LibraryOpenAL = { console.error("alBufferData called with invalid format " + format); return; } - AL.currentContext.buf[buffer].buf = AL.currentContext.ctx.createBuffer(channels, size / (bytes * channels), freq); + AL.currentContext.buf[buffer - 1].buf = AL.currentContext.ctx.createBuffer(channels, size / (bytes * channels), freq); var data = new Array(channels); for (var i = 0; i < channels; ++i) { - data[i] = AL.currentContext.buf[buffer].buf.getChannelData(i); + data[i] = AL.currentContext.buf[buffer - 1].buf.getChannelData(i); } for (var i = 0; i < size / (bytes * channels); ++i) { for (var j = 0; j < channels; ++j) { |