BugFix: asdf_buffer_get: check for valid handle

Was only testing for handle less than next_handle, but not checking for
negative handle values. Fixed to use buffer_handle_valid() to test for a
valid handle.
This commit is contained in:
David Fenyes 2021-12-14 11:31:39 -06:00
parent 118065236b
commit e13c9d6888

View File

@ -193,7 +193,7 @@ void asdf_buffer_put(asdf_buffer_handle_t handle, asdf_keycode_t code)
asdf_keycode_t asdf_buffer_get(asdf_buffer_handle_t handle)
{
asdf_keycode_t code = ASDF_INVALID_CODE;
if (handle < next_handle && buffers[handle].count) {
if (buffer_handle_valid(handle) && buffers[handle].count) {
code = buffers[handle].buf[buffers[handle].tail];
buffers[handle].tail = (buffers[handle].tail + 1) % buffers[handle].size;
buffers[handle].count--;