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

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 2349613002: Fix int overflow in GLES2DecoderImpl::DoDrawArrays (Closed)
Patch Set: Created 4 years, 3 months 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 | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/gles2_cmd_decoder.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 86074df50854075905257ab394e55fb06e0683f7..a3c4575497f7fbeb0126d5d214975354c502125e 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -9367,7 +9367,11 @@ error::Error GLES2DecoderImpl::DoDrawArrays(
return error::kNoError;
}
- GLuint max_vertex_accessed = first + count - 1;
+ base::CheckedNumeric<GLuint> checked_max_vertex = first;
+ checked_max_vertex += count - 1;
+ // first and count-1 are both a non-negative int, so their sum fits an
+ // unsigned int.
+ GLuint max_vertex_accessed = checked_max_vertex.ValueOrDie();
if (IsDrawValid(function_name, max_vertex_accessed, instanced, primcount)) {
if (!ClearUnclearedTextures()) {
LOCAL_SET_GL_ERROR(GL_INVALID_VALUE, function_name, "out of memory");
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698