diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-06-10 12:51:52 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-06-10 12:51:52 -0400 |
commit | ce6d7f43e7ad77b3eec043ff731d17ab21e89e87 (patch) | |
tree | a1a2b25054c0b6f529c5cd7a3c8d93c54f9597a5 | |
parent | fb65c9cc91fe5bcf75e1519bd73d31242fbccb9d (diff) |
Fix double ended queue index to use bounds check.
-rw-r--r-- | collections/double_ended_queue.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index f8f59e4..e737d28 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -107,15 +107,10 @@ int index; { void **tmp; - if (!root || index > root->limit - || (index >= root->end && index < root->beg)) - return NULL; - - index = (root->beg + index) % root->limit; - if (index >= root->end) + if (!root || !DEQ_IN_BOUNDS(root,index)) return NULL; - return root->base[index]; + return root->base[(root->beg + index) % root->limit]; } void deq_push_back(root, item) |