Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(749)

Unified Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp

Issue 1414853008: Validate pixel data array is enough for request by texImage3D and texSubImage3D (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
diff --git a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
index 04a9eecec34188a5d07a5b0806378d7682cd9354..0ebe65a9a75c7524461058e906c249ea0e901345 100644
--- a/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
+++ b/third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.cpp
@@ -4284,7 +4284,7 @@ void WebGLRenderingContextBase::texImage2D(GLenum target, GLint level, GLenum in
GLenum format, GLenum type, DOMArrayBufferView* pixels)
{
if (isContextLost() || !validateTexFunc("texImage2D", NotTexSubImage2D, SourceArrayBufferView, target, level, internalformat, width, height, border, format, type, 0, 0)
- || !validateTexFuncData("texImage2D", level, width, height, format, type, pixels, NullAllowed))
+ || !validateTexFuncData("texImage2D", level, width, height, 1, format, type, pixels, NullAllowed))
return;
void* data = pixels ? pixels->baseAddress() : 0;
Vector<uint8_t> tempData;
@@ -4608,7 +4608,7 @@ void WebGLRenderingContextBase::texSubImage2D(GLenum target, GLint level, GLint
GLenum format, GLenum type, DOMArrayBufferView* pixels)
{
if (isContextLost() || !validateTexFunc("texSubImage2D", TexSubImage2D, SourceArrayBufferView, target, level, 0, width, height, 0, format, type, xoffset, yoffset)
- || !validateTexFuncData("texSubImage2D", level, width, height, format, type, pixels, NullNotAllowed))
+ || !validateTexFuncData("texSubImage2D", level, width, height, 1, format, type, pixels, NullNotAllowed))
return;
void* data = pixels->baseAddress();
Vector<uint8_t> tempData;
@@ -5699,7 +5699,7 @@ bool WebGLRenderingContextBase::validateTexFuncParameters(const char* functionNa
return true;
}
-bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition)
+bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GLint level, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, DOMArrayBufferView* pixels, NullDisposition disposition)
{
// All calling functions check isContextLost, so a duplicate check is not needed here.
if (!pixels) {
@@ -5777,6 +5777,7 @@ bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL
unsigned totalBytesRequired;
GLenum error = WebGLImageConversion::computeImageSizeInBytes(format, type, width, height, m_unpackAlignment, &totalBytesRequired, 0);
+ totalBytesRequired *= depth;
Zhenyao Mo 2015/11/12 02:01:20 This is a bad hack. You should add the |depth| in
qiankun 2015/11/12 05:46:19 Thanks. I passed depth to WebGLImageConversion::c
if (error != GL_NO_ERROR) {
synthesizeGLError(error, functionName, "invalid texture dimensions");
return false;
@@ -5784,6 +5785,7 @@ bool WebGLRenderingContextBase::validateTexFuncData(const char* functionName, GL
if (pixels->byteLength() < totalBytesRequired) {
if (m_unpackAlignment != 1) {
error = WebGLImageConversion::computeImageSizeInBytes(format, type, width, height, 1, &totalBytesRequired, 0);
+ totalBytesRequired *= depth;
if (pixels->byteLength() == totalBytesRequired) {
synthesizeGLError(GL_INVALID_OPERATION, functionName, "ArrayBufferView not big enough for request with UNPACK_ALIGNMENT > 1");
return false;
« no previous file with comments | « third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698