summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/angle
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2013-04-05 15:14:46 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-08 11:35:44 +0200
commitdce86de8e79d91952c7b21f3bd63bcb1b9f9e7e9 (patch)
tree57e9210eb8fbab66736ef35dc79bcafdd88f8b1c /src/3rdparty/angle
parentfab430a4120a74a76862de718eaf2740366d9875 (diff)
ANGLE: Avoid memory copies on buffers when data is null
With data=0, ANGLE can crash when setting the buffer data. As this should be a legal operation, don't perform a memcpy when data is null. Change-Id: I3fa1260482549b1da50d7a68001a65decb98f258 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/3rdparty/angle')
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp22
-rw-r--r--src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp3
2 files changed, 18 insertions, 7 deletions
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp
index 4c37bdbf60..7fe9e6b762 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage11.cpp
@@ -182,7 +182,8 @@ void BufferStorage11::setData(const void* data, unsigned int size, unsigned int
return gl::error(GL_OUT_OF_MEMORY);
}
- memcpy(mappedResource.pData, data, size);
+ if (data)
+ memcpy(mappedResource.pData, data, size);
context->Unmap(mStagingBuffer, 0);
}
@@ -211,12 +212,21 @@ void BufferStorage11::setData(const void* data, unsigned int size, unsigned int
mBufferSize = 0;
}
- D3D11_SUBRESOURCE_DATA initialData;
- initialData.pSysMem = data;
- initialData.SysMemPitch = size;
- initialData.SysMemSlicePitch = 0;
- result = device->CreateBuffer(&bufferDesc, &initialData, &mBuffer);
+ if (data)
+ {
+ D3D11_SUBRESOURCE_DATA initialData;
+ initialData.pSysMem = data;
+ initialData.SysMemPitch = size;
+ initialData.SysMemSlicePitch = 0;
+
+ result = device->CreateBuffer(&bufferDesc, &initialData, &mBuffer);
+ }
+ else
+ {
+ result = device->CreateBuffer(&bufferDesc, NULL, &mBuffer);
+ }
+
if (FAILED(result))
{
return gl::error(GL_OUT_OF_MEMORY);
diff --git a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp
index 7fc14fc073..4468461871 100644
--- a/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp
+++ b/src/3rdparty/angle/src/libGLESv2/renderer/BufferStorage9.cpp
@@ -54,7 +54,8 @@ void BufferStorage9::setData(const void* data, unsigned int size, unsigned int o
}
mSize = std::max(mSize, offset + size);
- memcpy(reinterpret_cast<char*>(mMemory) + offset, data, size);
+ if (data)
+ memcpy(reinterpret_cast<char*>(mMemory) + offset, data, size);
}
void BufferStorage9::clear()