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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.cc

Issue 2892663004: Fix signed integer overflow in gles2_cmd_decoder_unittest_extensions.cc (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 delete_cmd.Init(0, 1); 582 delete_cmd.Init(0, 1);
583 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 583 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
584 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 584 EXPECT_EQ(GL_NO_ERROR, GetGLError());
585 585
586 // DeletePaths with a big range should not cause any deletes. 586 // DeletePaths with a big range should not cause any deletes.
587 delete_cmd.Init(client_path_id_ + 1, 587 delete_cmd.Init(client_path_id_ + 1,
588 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1); 588 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1);
589 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 589 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
590 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 590 EXPECT_EQ(GL_NO_ERROR, GetGLError());
591 591
592 delete_cmd.Init(std::numeric_limits<GLsizei>::max() + 1, 592 delete_cmd.Init(static_cast<GLuint>(std::numeric_limits<GLsizei>::max()) + 1,
Nico 2017/05/18 17:40:23 Isn't GLsizei an unsigned type already? And can't
hans 2017/05/18 17:48:20 No, it's signed.
593 std::numeric_limits<GLsizei>::max()); 593 std::numeric_limits<GLsizei>::max());
594 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 594 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
595 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 595 EXPECT_EQ(GL_NO_ERROR, GetGLError());
596 596
597 // Normal Gen and Delete should cause the normal calls. 597 // Normal Gen and Delete should cause the normal calls.
598 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) 598 EXPECT_CALL(*gl_, GenPathsNV(kPathCount))
599 .WillOnce(Return(kFirstCreatedServiceID)) 599 .WillOnce(Return(kFirstCreatedServiceID))
600 .RetiresOnSaturation(); 600 .RetiresOnSaturation();
601 601
602 gen_cmd.Init(kFirstClientID, kPathCount); 602 gen_cmd.Init(kFirstClientID, kPathCount);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 gen_cmd.Init(kFirstClientID, -1); 768 gen_cmd.Init(kFirstClientID, -1);
769 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); 769 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd));
770 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 770 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
771 771
772 // Path 0 is invalid client id, connection error. 772 // Path 0 is invalid client id, connection error.
773 gen_cmd.Init(0, kPathCount); 773 gen_cmd.Init(0, kPathCount);
774 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); 774 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd));
775 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 775 EXPECT_EQ(GL_NO_ERROR, GetGLError());
776 776
777 // Too big range causes client id to wrap, connection error. 777 // Too big range causes client id to wrap, connection error.
778 gen_cmd.Init(std::numeric_limits<GLsizei>::max() + 3, 778 gen_cmd.Init(static_cast<GLuint>(std::numeric_limits<GLsizei>::max()) + 3,
779 std::numeric_limits<GLsizei>::max()); 779 std::numeric_limits<GLsizei>::max());
780 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); 780 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd));
781 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 781 EXPECT_EQ(GL_NO_ERROR, GetGLError());
782 782
783 // Creating duplicate client_ids cause connection error. 783 // Creating duplicate client_ids cause connection error.
784 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) 784 EXPECT_CALL(*gl_, GenPathsNV(kPathCount))
785 .WillOnce(Return(kFirstCreatedServiceID)) 785 .WillOnce(Return(kFirstCreatedServiceID))
786 .RetiresOnSaturation(); 786 .RetiresOnSaturation();
787 787
788 gen_cmd.Init(kFirstClientID, kPathCount); 788 gen_cmd.Init(kFirstClientID, kPathCount);
(...skipping 23 matching lines...) Expand all
812 DeletePathsCHROMIUMInvalidCalls) { 812 DeletePathsCHROMIUMInvalidCalls) {
813 static GLuint kFirstClientID = client_path_id_ + 88; 813 static GLuint kFirstClientID = client_path_id_ + 88;
814 814
815 // Range < 0 is causes gl error. 815 // Range < 0 is causes gl error.
816 cmds::DeletePathsCHROMIUM delete_cmd; 816 cmds::DeletePathsCHROMIUM delete_cmd;
817 delete_cmd.Init(kFirstClientID, -1); 817 delete_cmd.Init(kFirstClientID, -1);
818 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); 818 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
819 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); 819 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
820 820
821 // Too big range causes client id to wrap, connection error. 821 // Too big range causes client id to wrap, connection error.
822 delete_cmd.Init(std::numeric_limits<GLsizei>::max() + 3, 822 delete_cmd.Init(static_cast<GLuint>(std::numeric_limits<GLsizei>::max()) + 3,
823 std::numeric_limits<GLsizei>::max()); 823 std::numeric_limits<GLsizei>::max());
824 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(delete_cmd)); 824 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(delete_cmd));
825 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 825 EXPECT_EQ(GL_NO_ERROR, GetGLError());
826 } 826 }
827 827
828 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, 828 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
829 PathCommandsCHROMIUMInvalidCalls) { 829 PathCommandsCHROMIUMInvalidCalls) {
830 static const GLsizei kCorrectCoordCount = 19; 830 static const GLsizei kCorrectCoordCount = 19;
831 static const GLsizei kCorrectCommandCount = 6; 831 static const GLsizei kCorrectCommandCount = 6;
832 static const GLenum kInvalidCoordType = GL_NONE; 832 static const GLenum kInvalidCoordType = GL_NONE;
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
1721 SetBucketAsCString(kBucketId, kBadName1); 1721 SetBucketAsCString(kBucketId, kBadName1);
1722 cmd.Init(client_program_id_, kLocation, kBucketId); 1722 cmd.Init(client_program_id_, kLocation, kBucketId);
1723 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1723 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1724 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1724 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1725 } 1725 }
1726 1726
1727 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h" 1727 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h"
1728 1728
1729 } // namespace gles2 1729 } // namespace gles2
1730 } // namespace gpu 1730 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698