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

Side by Side Diff: core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp

Issue 384593002: Fix uninitialized coords in _DrawCoonPatchMeshes (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 5 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 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../../include/fpdfapi/fpdf_render.h" 7 #include "../../../include/fpdfapi/fpdf_render.h"
8 #include "../../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 #include "../fpdf_page/pageint.h" 10 #include "../fpdf_page/pageint.h"
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 patch.alpha = alpha; 681 patch.alpha = alpha;
682 patch.pDevice = &device; 682 patch.pDevice = &device;
683 patch.fill_mode = fill_mode; 683 patch.fill_mode = fill_mode;
684 patch.path.SetPointCount(13); 684 patch.path.SetPointCount(13);
685 FX_PATHPOINT* pPoints = patch.path.GetPoints(); 685 FX_PATHPOINT* pPoints = patch.path.GetPoints();
686 pPoints[0].m_Flag = FXPT_MOVETO; 686 pPoints[0].m_Flag = FXPT_MOVETO;
687 for (int i = 1; i < 13; i ++) { 687 for (int i = 1; i < 13; i ++) {
688 pPoints[i].m_Flag = FXPT_BEZIERTO; 688 pPoints[i].m_Flag = FXPT_BEZIERTO;
689 } 689 }
690 CFX_FloatPoint coords[16]; 690 CFX_FloatPoint coords[16];
691 for (int i = 0; i < 16; i ++)
palmer 2014/07/10 23:11:01 This is fine. But a more elegant solution is to d
jun_fang 2014/07/15 01:13:41 CFX_FloatPoint is created by CFX_PSVTTemplate<FX_F
palmer 2014/07/15 01:49:17 Yes. I am saying, you could give that template a d
jun_fang 2014/07/15 03:56:17 :-). I know. I tried to add a default constructor.
Ryan Sleevi 2014/07/15 23:59:00 Just happened to see this CL go by. The nice thing
692 {
693 coords[i].Set(0.0f, 0.0f);
694 }
695
691 int point_count = bTensor ? 16 : 12; 696 int point_count = bTensor ? 16 : 12;
692 while (!stream.m_BitStream.IsEOF()) { 697 while (!stream.m_BitStream.IsEOF()) {
693 FX_DWORD flag = stream.GetFlag(); 698 FX_DWORD flag = stream.GetFlag();
palmer 2014/07/10 23:11:01 Because this value is untrustworthy (comes from th
jun_fang 2014/07/15 01:13:41 The value from GetFlag() is limited to 0 to 3. The
palmer 2014/07/15 01:49:17 Acknowledged.
694 int iStartPoint = 0, iStartColor = 0, i; 699 int iStartPoint = 0, iStartColor = 0, i;
695 if (flag) { 700 if (flag) {
696 iStartPoint = 4; 701 iStartPoint = 4;
697 iStartColor = 2; 702 iStartColor = 2;
698 CFX_FloatPoint tempCoords[4]; 703 CFX_FloatPoint tempCoords[4];
699 for (int i = 0; i < 4; i ++) { 704 for (int i = 0; i < 4; i ++) {
700 tempCoords[i] = coords[(flag * 3 + i) % 12]; 705 tempCoords[i] = coords[(flag * 3 + i) % 12];
701 } 706 }
702 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4); 707 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4);
703 Coon_Color tempColors[2]; 708 Coon_Color tempColors[2];
704 tempColors[0] = patch.patch_colors[flag]; 709 tempColors[0] = patch.patch_colors[flag];
palmer 2014/07/10 23:11:01 ... this could be an out-of-bounds read, I think.
jun_fang 2014/07/15 01:13:41 flag should be 0 to 3 as explained before. So it's
palmer 2014/07/15 01:49:17 Acknowledged.
705 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; 710 tempColors[1] = patch.patch_colors[(flag + 1) % 4];
706 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) * 2); 711 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) * 2);
707 } 712 }
708 for (i = iStartPoint; i < point_count; i ++) { 713 for (i = iStartPoint; i < point_count; i ++) {
709 stream.GetCoords(coords[i].x, coords[i].y); 714 stream.GetCoords(coords[i].x, coords[i].y);
710 pObject2Bitmap->Transform(coords[i].x, coords[i].y); 715 pObject2Bitmap->Transform(coords[i].x, coords[i].y);
711 } 716 }
712 for (i = iStartColor; i < 4; i ++) { 717 for (i = iStartColor; i < 4; i ++) {
713 FX_FLOAT r=0.0f, g=0.0f, b=0.0f; 718 FX_FLOAT r=0.0f, g=0.0f, b=0.0f;
714 stream.GetColor(r, g, b); 719 stream.GetColor(r, g, b);
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 bStroke = FALSE; 1089 bStroke = FALSE;
1085 bPattern = TRUE; 1090 bPattern = TRUE;
1086 } 1091 }
1087 } 1092 }
1088 #ifdef _FPDFAPI_MINI_ 1093 #ifdef _FPDFAPI_MINI_
1089 if (bPattern && m_DitherBits) { 1094 if (bPattern && m_DitherBits) {
1090 DitherObjectArea(pPathObj, pObj2Device); 1095 DitherObjectArea(pPathObj, pObj2Device);
1091 } 1096 }
1092 #endif 1097 #endif
1093 } 1098 }
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