Allow calling HandleAllocator::reserve with MAX_UINT.
BUG=angleproject:1052
Change-Id: I03883799ef334f39c9e855a0a4b7af1ab02d5da9
Reviewed-on: https://chromium-review.googlesource.com/282414
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Minmin Gong <mgong@microsoft.com>
diff --git a/src/libANGLE/HandleAllocator.cpp b/src/libANGLE/HandleAllocator.cpp
index 59d3966..1b9162a 100644
--- a/src/libANGLE/HandleAllocator.cpp
+++ b/src/libANGLE/HandleAllocator.cpp
@@ -26,7 +26,7 @@
HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
{
- mUnallocatedList.push_back(HandleRange(1, std::numeric_limits<GLuint>::max() - 1));
+ mUnallocatedList.push_back(HandleRange(1, std::numeric_limits<GLuint>::max()));
}
HandleAllocator::HandleAllocator(GLuint maximumHandleValue) : mBaseValue(1), mNextValue(1)
diff --git a/src/libANGLE/HandleAllocator_unittest.cpp b/src/libANGLE/HandleAllocator_unittest.cpp
index be067dc..196b346 100644
--- a/src/libANGLE/HandleAllocator_unittest.cpp
+++ b/src/libANGLE/HandleAllocator_unittest.cpp
@@ -90,4 +90,17 @@
EXPECT_EQ(finalResult, 1);
}
+// The following test covers reserving a handle with max uint value.
+// See http://anglebug.com/1052
+TEST(HandleAllocatorTest, ReserveMaxUintHandle)
+{
+ gl::HandleAllocator allocator;
+
+ GLuint maxUintHandle = std::numeric_limits<GLuint>::max();
+ allocator.reserve(maxUintHandle);
+
+ GLuint normalHandle = allocator.allocate();
+ EXPECT_EQ(1u, normalHandle);
+}
+
}