Avoid potential overflow in VA_Excise

Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ed096ff4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ed096ff4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ed096ff4

Branch: refs/heads/master
Commit: ed096ff47a3d92eb06a2204b8352043a32c5fc58
Parents: 2db62be
Author: Nick Wellnhofer <[email protected]>
Authored: Thu Apr 23 14:33:51 2015 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Thu Apr 23 14:33:51 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/VArray.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ed096ff4/runtime/core/Clownfish/VArray.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/VArray.c b/runtime/core/Clownfish/VArray.c
index f395c6d..294e342 100644
--- a/runtime/core/Clownfish/VArray.c
+++ b/runtime/core/Clownfish/VArray.c
@@ -199,8 +199,8 @@ VA_Delete_IMP(VArray *self, size_t num) {
 
 void
 VA_Excise_IMP(VArray *self, size_t offset, size_t length) {
-    if (self->size <= offset)              { return; }
-    else if (self->size < offset + length) { length = self->size - offset; }
+    if (offset >= self->size)         { return; }
+    if (length > self->size - offset) { length = self->size - offset; }
 
     for (size_t i = 0; i < length; i++) {
         DECREF(self->elems[offset + i]);

Reply via email to