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

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

Issue 372453005: Fix uninitialized coords and one of infinite loops (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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 left *= 2; 658 left *= 2;
659 bottom *= 2; 659 bottom *= 2;
660 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi rst_half(), m2f); 660 Draw(x_scale, y_scale, left, bottom, C1.first_half(), m1f, D1.fi rst_half(), m2f);
661 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D 1.second_half(), m2s); 661 Draw(x_scale, y_scale, left, bottom + 1, m1f, C2.first_half(), D 1.second_half(), m2s);
662 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s, m2f, D2.first_half()); 662 Draw(x_scale, y_scale, left + 1, bottom, C1.second_half(), m1s, m2f, D2.first_half());
663 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half (), m2s, D2.second_half()); 663 Draw(x_scale, y_scale, left + 1, bottom + 1, m1s, C2.second_half (), m2s, D2.second_half());
664 } 664 }
665 } 665 }
666 } 666 }
667 }; 667 };
668
669 static FX_BOOL _CheckCoonTensorPara(CPDF_MeshStream& stream)
Tom Sepez 2014/07/22 17:28:51 nit: const CPDF_MeshStream&
670 {
671 FX_BOOL bCoorBits = ( stream.m_nCoordBits == 1 ||
672 stream.m_nCoordBits == 2 ||
673 stream.m_nCoordBits == 4 ||
674 stream.m_nCoordBits == 8 ||
675 stream.m_nCoordBits == 12 ||
676 stream.m_nCoordBits == 16 ||
677 stream.m_nCoordBits == 24 ||
678 stream.m_nCoordBits == 32 );
679
680 FX_BOOL bCompBits = ( stream.m_nCompBits == 1 ||
681 stream.m_nCompBits == 2 ||
682 stream.m_nCompBits == 4 ||
683 stream.m_nCompBits == 8 ||
684 stream.m_nCompBits == 12 ||
685 stream.m_nCompBits == 16 );
686
687 FX_BOOL bFlagBits = ( stream.m_nFlagBits == 2 ||
688 stream.m_nFlagBits == 4 ||
689 stream.m_nFlagBits == 8 );
690
691 return bCoorBits && bCompBits && bFlagBits;
692 }
693
668 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, CFX_DIBitmap* pBitmap, CFX_Aff ineMatrix* pObject2Bitmap, 694 static void _DrawCoonPatchMeshes(FX_BOOL bTensor, CFX_DIBitmap* pBitmap, CFX_Aff ineMatrix* pObject2Bitmap,
669 CPDF_Stream* pShadingStream, CPDF_Function** pF uncs, int nFuncs, 695 CPDF_Stream* pShadingStream, CPDF_Function** pF uncs, int nFuncs,
670 CPDF_ColorSpace* pCS, int fill_mode, int alpha) 696 CPDF_ColorSpace* pCS, int fill_mode, int alpha)
671 { 697 {
672 ASSERT(pBitmap->GetFormat() == FXDIB_Argb); 698 ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
673 if (pShadingStream->GetType() != PDFOBJ_STREAM) { 699 if (pShadingStream->GetType() != PDFOBJ_STREAM) {
674 return; 700 return;
675 } 701 }
676 CFX_FxgeDevice device; 702 CFX_FxgeDevice device;
677 device.Attach(pBitmap); 703 device.Attach(pBitmap);
678 CPDF_MeshStream stream; 704 CPDF_MeshStream stream;
679 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) { 705 if (!stream.Load(pShadingStream, pFuncs, nFuncs, pCS)) {
680 return; 706 return;
681 } 707 }
708 if (!_CheckCoonTensorPara(stream)){
Tom Sepez 2014/07/22 17:27:21 nit: space before { to match existing style in fil
709 return;
710 }
682 CPDF_PatchDrawer patch; 711 CPDF_PatchDrawer patch;
683 patch.alpha = alpha; 712 patch.alpha = alpha;
684 patch.pDevice = &device; 713 patch.pDevice = &device;
685 patch.fill_mode = fill_mode; 714 patch.fill_mode = fill_mode;
686 patch.path.SetPointCount(13); 715 patch.path.SetPointCount(13);
687 FX_PATHPOINT* pPoints = patch.path.GetPoints(); 716 FX_PATHPOINT* pPoints = patch.path.GetPoints();
688 pPoints[0].m_Flag = FXPT_MOVETO; 717 pPoints[0].m_Flag = FXPT_MOVETO;
689 for (int i = 1; i < 13; i ++) { 718 for (int i = 1; i < 13; i ++) {
690 pPoints[i].m_Flag = FXPT_BEZIERTO; 719 pPoints[i].m_Flag = FXPT_BEZIERTO;
691 } 720 }
692 CFX_FloatPoint coords[16]; 721 CFX_FloatPoint coords[16];
693 for (int i = 0; i < 16; i ++) 722 for (int i = 0; i < 16; i ++){
Tom Sepez 2014/07/22 17:27:21 nit: space before { to match existing style in fil
694 {
695 coords[i].Set(0.0f, 0.0f); 723 coords[i].Set(0.0f, 0.0f);
696 } 724 }
697 725
698 int point_count = bTensor ? 16 : 12; 726 int point_count = bTensor ? 16 : 12;
699 while (!stream.m_BitStream.IsEOF()) { 727 while (!stream.m_BitStream.IsEOF()) {
700 FX_DWORD flag = stream.GetFlag(); 728 FX_DWORD flag = stream.GetFlag();
701 int iStartPoint = 0, iStartColor = 0, i; 729 int iStartPoint = 0, iStartColor = 0, i = 0;
Tom Sepez 2014/07/22 17:27:21 nit: initialized value isn't used. reset to 0 in
702 if (flag) { 730 if (flag) {
703 iStartPoint = 4; 731 iStartPoint = 4;
704 iStartColor = 2; 732 iStartColor = 2;
705 CFX_FloatPoint tempCoords[4]; 733 CFX_FloatPoint tempCoords[4];
706 for (int i = 0; i < 4; i ++) { 734 for (i = 0; i < 4; i ++) {
707 tempCoords[i] = coords[(flag * 3 + i) % 12]; 735 tempCoords[i] = coords[(flag * 3 + i) % 12];
708 } 736 }
709 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4); 737 FXSYS_memcpy32(coords, tempCoords, sizeof(CFX_FloatPoint) * 4);
710 Coon_Color tempColors[2]; 738 Coon_Color tempColors[2];
711 tempColors[0] = patch.patch_colors[flag]; 739 tempColors[0] = patch.patch_colors[flag];
712 tempColors[1] = patch.patch_colors[(flag + 1) % 4]; 740 tempColors[1] = patch.patch_colors[(flag + 1) % 4];
713 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) * 2); 741 FXSYS_memcpy32(patch.patch_colors, tempColors, sizeof(Coon_Color) * 2);
714 } 742 }
715 for (i = iStartPoint; i < point_count; i ++) { 743 for (i = iStartPoint; i < point_count; i ++) {
716 stream.GetCoords(coords[i].x, coords[i].y); 744 stream.GetCoords(coords[i].x, coords[i].y);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 bStroke = FALSE; 1119 bStroke = FALSE;
1092 bPattern = TRUE; 1120 bPattern = TRUE;
1093 } 1121 }
1094 } 1122 }
1095 #ifdef _FPDFAPI_MINI_ 1123 #ifdef _FPDFAPI_MINI_
1096 if (bPattern && m_DitherBits) { 1124 if (bPattern && m_DitherBits) {
1097 DitherObjectArea(pPathObj, pObj2Device); 1125 DitherObjectArea(pPathObj, pObj2Device);
1098 } 1126 }
1099 #endif 1127 #endif
1100 } 1128 }
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