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

Unified Diff: fpdfsdk/src/pdfwindow/PWL_Edit.cpp

Issue 461343003: Check path point count overflow in DrawThisAppearance (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/pdfwindow/PWL_Edit.cpp
diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
index df59c2ccc80d3ad85dfed462835eddad7fbb466f..e2b7a564404733055af3219c4ef6ad63e8319438 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
@@ -411,8 +411,11 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
CFX_ByteTextBuf sLine;
FX_INT32 nCharArray = m_pEdit->GetCharArray();
+ FX_SAFE_INT32 nCharArrayDouble = nCharArray;
Tom Sepez 2014/08/18 18:15:47 nit: Can we call this nCharArraySafe? Double soun
Bo Xu 2014/08/18 18:33:58 Done.
+ nCharArrayDouble -= 1;
+ nCharArrayDouble *= 2;
- if (nCharArray > 0)
+ if (nCharArray > 0 && nCharArrayDouble.IsValid())
{
switch (GetBorderStyle())
{
@@ -422,7 +425,9 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
CFX_PathData path;
- path.SetPointCount((nCharArray-1)*2);
+ if (!path.SetPointCount(nCharArrayDouble.ValueOrDie())) {
+ return;
+ }
for (FX_INT32 i=0; i<nCharArray-1; i++)
{
@@ -447,7 +452,9 @@ void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser
gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
CFX_PathData path;
- path.SetPointCount((nCharArray-1)*2);
+ if (!path.SetPointCount(nCharArrayDouble.ValueOrDie())) {
+ return;
+ }
for (FX_INT32 i=0; i<nCharArray-1; i++)
{
« 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