Change the offset variable to an unsigned int since it cannot be negative and is assigned to streamOffset which is an unsigned int.

TRAC #23671

Signed-off-by: Nicolas Capens
Signed-off-by: Shannon Woods
Author: Geoff Lang
diff --git a/src/libGLESv2/renderer/IndexDataManager.cpp b/src/libGLESv2/renderer/IndexDataManager.cpp
index 2eab550..8197e57 100644
--- a/src/libGLESv2/renderer/IndexDataManager.cpp
+++ b/src/libGLESv2/renderer/IndexDataManager.cpp
@@ -115,13 +115,19 @@
     }
 
     GLenum destinationIndexType = (type == GL_UNSIGNED_INT) ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT;
-    intptr_t offset = reinterpret_cast<intptr_t>(indices);
+    unsigned int offset = 0;
     bool alignedOffset = false;
 
     BufferStorage *storage = NULL;
 
     if (buffer != NULL)
     {
+        if (reinterpret_cast<uintptr_t>(indices) > std::numeric_limits<unsigned int>::max())
+        {
+            return GL_OUT_OF_MEMORY;
+        }
+        offset = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(indices));
+
         storage = buffer->getStorage();
 
         switch (type)
diff --git a/src/libGLESv2/renderer/IndexRangeCache.cpp b/src/libGLESv2/renderer/IndexRangeCache.cpp
index 7630934..610a5ef 100644
--- a/src/libGLESv2/renderer/IndexRangeCache.cpp
+++ b/src/libGLESv2/renderer/IndexRangeCache.cpp
@@ -16,7 +16,7 @@
 namespace rx
 {
 
-void IndexRangeCache::addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, 
+void IndexRangeCache::addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
                                unsigned int streamOffset)
 {
     mIndexRangeCache[IndexRange(type, offset, count)] = IndexBounds(minIdx, maxIdx, streamOffset);
@@ -44,7 +44,7 @@
     }
 }
 
-bool IndexRangeCache::findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex,
+bool IndexRangeCache::findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex,
                                 unsigned int *outMaxIndex, unsigned int *outStreamOffset) const
 {
     IndexRangeMap::const_iterator i = mIndexRangeCache.find(IndexRange(type, offset, count));
diff --git a/src/libGLESv2/renderer/IndexRangeCache.h b/src/libGLESv2/renderer/IndexRangeCache.h
index 5a5ade1..5683430 100644
--- a/src/libGLESv2/renderer/IndexRangeCache.h
+++ b/src/libGLESv2/renderer/IndexRangeCache.h
@@ -18,9 +18,9 @@
 class IndexRangeCache
 {
   public:
-    void addRange(GLenum type, intptr_t offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx, 
+    void addRange(GLenum type, unsigned int offset, GLsizei count, unsigned int minIdx, unsigned int maxIdx,
                   unsigned int streamOffset);
-    bool findRange(GLenum type, intptr_t offset, GLsizei count, unsigned int *outMinIndex,
+    bool findRange(GLenum type, unsigned int offset, GLsizei count, unsigned int *outMinIndex,
                    unsigned int *outMaxIndex, unsigned int *outStreamOffset) const;
 
     void invalidateRange(unsigned int offset, unsigned int size);
@@ -30,7 +30,7 @@
     struct IndexRange
     {
         GLenum type;
-        intptr_t offset;
+        unsigned int offset;
         GLsizei count;
 
         IndexRange();