Index: gpu/command_buffer/client/gles2_implementation.cc |
diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc |
index aa3b18d4e783c28b8bb69de4ca9198c64856346c..ee37d267a41fbdfe6ca5d83b77b9ca6bba8d6384 100644 |
--- a/gpu/command_buffer/client/gles2_implementation.cc |
+++ b/gpu/command_buffer/client/gles2_implementation.cc |
@@ -19,6 +19,7 @@ |
#include <string> |
#include "base/atomic_sequence_num.h" |
#include "base/compiler_specific.h" |
+#include "base/numerics/safe_math.h" |
#include "base/strings/string_split.h" |
#include "base/strings/stringprintf.h" |
#include "base/sys_info.h" |
@@ -2875,6 +2876,12 @@ void GLES2Implementation::TexSubImage2D( |
pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
+ base::CheckedNumeric<GLint> checked_yoffset = yoffset; |
Zhenyao Mo
2016/09/07 21:03:18
Let's do xoffset + width also.
xidachen
2016/09/07 23:05:19
Done.
|
+ checked_yoffset += height; |
+ if (!checked_yoffset.IsValid()) { |
+ SetGLError(GL_INVALID_VALUE, "TexSubImage2D", "yoffset + height overflows"); |
+ return; |
+ } |
TexSubImage2DImpl( |
target, level, xoffset, yoffset, width, height, format, type, |
unpadded_row_size, pixels, padded_row_size, GL_FALSE, &buffer, |
@@ -3000,6 +3007,18 @@ void GLES2Implementation::TexSubImage3D( |
pixels = reinterpret_cast<const int8_t*>(pixels) + skip_size; |
ScopedTransferBufferPtr buffer(size, helper_, transfer_buffer_); |
+ base::CheckedNumeric<GLint> checked_yoffset = yoffset; |
+ checked_yoffset += height; |
+ if (!checked_yoffset.IsValid()) { |
+ SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "yoffset + height overflows"); |
+ return; |
+ } |
+ base::CheckedNumeric<GLint> checked_zoffset = zoffset; |
+ checked_zoffset += depth; |
+ if (!checked_zoffset.IsValid()) { |
+ SetGLError(GL_INVALID_VALUE, "TexSubImage3D", "zoffset + depth overflows"); |
+ return; |
+ } |
TexSubImage3DImpl( |
target, level, xoffset, yoffset, zoffset, width, height, depth, |
format, type, unpadded_row_size, pixels, padded_row_size, GL_FALSE, |