Check that IDirect3DVertexBuffer9 and IDirect3DIndexBuffer9::Lock succeed.
I've been seeing crashes like this on Windows XP:
0x013319aa [libglesv2.dll - memcpy.asm:188] memcpy
0x0130989a [libglesv2.dll - vertexdatamanager.cpp:164] gl::VertexDataManager::preRenderValidate(int,int,gl::TranslatedAttribute *)
0x01304f66 [libglesv2.dll - context.cpp:1996] gl::Context::applyVertexBuffer(unsigned int,int,int,bool *,gl::TranslatedIndexData *)
0x013061a7 [libglesv2.dll - context.cpp:2648] gl::Context::drawArrays(unsigned int,int,int)
0x012f7721 [libglesv2.dll - libglesv2.cpp:1741] glDrawArrays
0x01c54f1e [chrome.dll - gles2_cmd_decoder.cc:3179] gpu::gles2::GLES2DecoderImpl::DoDrawArrays(unsigned int,int,int)
0x01c59122 [chrome.dll - gles2_cmd_decoder_autogen.h:640] gpu::gles2::GLES2DecoderImpl::HandleDrawArrays(unsigned int,gpu::gles2::DrawArrays const &)
Review URL: http://codereview.appspot.com/3043042
git-svn-id: https://angleproject.googlecode.com/svn/trunk@480 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libGLESv2/geometry/IndexDataManager.cpp b/src/libGLESv2/geometry/IndexDataManager.cpp
index d573579..a8227a8 100644
--- a/src/libGLESv2/geometry/IndexDataManager.cpp
+++ b/src/libGLESv2/geometry/IndexDataManager.cpp
@@ -103,6 +103,11 @@
size_t offset;
void *output = streamIb->map(requiredSpace, &offset);
+ if (output == NULL)
+ {
+ ERR(" failed to map index buffer.");
+ return GL_OUT_OF_MEMORY;
+ }
translated->buffer = streamIb;
translated->offset = offset;
@@ -210,6 +215,11 @@
mLineLoopBuffer = mBackend->createIndexBuffer((count+1) * sizeof(unsigned short), GL_UNSIGNED_SHORT);
unsigned short *indices = static_cast<unsigned short *>(mLineLoopBuffer->map());
+ if (indices == NULL)
+ {
+ ERR(" failed to map index buffer.");
+ return GL_OUT_OF_MEMORY;
+ }
for (int i = 0; i < count; i++)
{
@@ -232,6 +242,11 @@
mCountingBuffer = mBackend->createIndexBuffer(count * sizeof(unsigned short), GL_UNSIGNED_SHORT);
unsigned short *indices = static_cast<unsigned short *>(mCountingBuffer->map());
+ if (indices == NULL)
+ {
+ ERR(" failed to map index buffer.");
+ return GL_OUT_OF_MEMORY;
+ }
for (int i = 0; i < count; i++)
{