diff options
author | andreykproductengine <andreykproductengine@lindenlab.com> | 2017-11-17 17:33:10 +0200 |
---|---|---|
committer | andreykproductengine <andreykproductengine@lindenlab.com> | 2017-11-17 17:33:10 +0200 |
commit | 8da9e0ffd73e30a55734864e49a6ec917e3bee00 (patch) | |
tree | b062acc70be7739b5c8116e0fef5ebb8ac5293c7 /indra | |
parent | 667f2fedef33b6fb217939290e6b097d7447de92 (diff) |
MAINT-72 unmapBuffer crash
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llrender/llvertexbuffer.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/indra/llrender/llvertexbuffer.cpp b/indra/llrender/llvertexbuffer.cpp index 6de2a973d2..8a4c21d6e4 100644 --- a/indra/llrender/llvertexbuffer.cpp +++ b/indra/llrender/llvertexbuffer.cpp @@ -1921,7 +1921,21 @@ void LLVertexBuffer::unmapBuffer() const MappedRegion& region = mMappedVertexRegions[i]; S32 offset = region.mIndex >= 0 ? mOffsets[region.mType]+sTypeSize[region.mType]*region.mIndex : 0; S32 length = sTypeSize[region.mType]*region.mCount; - glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedData+offset); + if (mSize >= length + offset) + { + glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, (U8*)mMappedData + offset); + } + else + { + GLint size = 0; + glGetBufferParameterivARB(GL_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + LL_WARNS() << "Attempted to map regions to a buffer that is too small, " + << "mapped size: " << mSize + << ", gl buffer size: " << size + << ", length: " << length + << ", offset: " << offset + << LL_ENDL; + } stop_glerror(); } @@ -1989,7 +2003,21 @@ void LLVertexBuffer::unmapBuffer() const MappedRegion& region = mMappedIndexRegions[i]; S32 offset = region.mIndex >= 0 ? sizeof(U16)*region.mIndex : 0; S32 length = sizeof(U16)*region.mCount; - glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedIndexData+offset); + if (mIndicesSize >= length + offset) + { + glBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, (U8*) mMappedIndexData+offset); + } + else + { + GLint size = 0; + glGetBufferParameterivARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &size); + LL_WARNS() << "Attempted to map regions to a buffer that is too small, " + << "mapped size: " << mIndicesSize + << ", gl buffer size: " << size + << ", length: " << length + << ", offset: " << offset + << LL_ENDL; + } stop_glerror(); } |