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

Unified Diff: core/fxge/dib/fx_dib_engine.cpp

Issue 2322903002: Strengthen bounds check in CWeightTable::Calc. (Closed)
Patch Set: Add helper method 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 | « core/fxge/dib/dib_int.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/dib/fx_dib_engine.cpp
diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/fx_dib_engine.cpp
index 88b0d4b271632ce2b7f6aac696e68c34cf6d2ae0..7ba031e8aafd28a0a83a2d27f4bd8bfdf1dd8962 100644
--- a/core/fxge/dib/fx_dib_engine.cpp
+++ b/core/fxge/dib/fx_dib_engine.cpp
@@ -41,6 +41,10 @@ CWeightTable::~CWeightTable() {
FX_Free(m_pWeightTables);
}
+size_t CWeightTable::GetPixelWeightSize() const {
+ return m_dwWeightTablesSize / sizeof(int);
+}
+
bool CWeightTable::Calc(int dest_len,
int dest_min,
int dest_max,
@@ -235,7 +239,7 @@ bool CWeightTable::Calc(int dest_len,
break;
}
size_t idx = j - start_i;
- if (idx >= m_dwWeightTablesSize)
+ if (idx >= GetPixelWeightSize())
return false;
pixel_weights.m_Weights[idx] = FXSYS_round((FX_FLOAT)(weight * 65536));
}
@@ -255,7 +259,7 @@ int* CWeightTable::GetValueFromPixelWeight(PixelWeight* pWeight,
return nullptr;
size_t idx = index - pWeight->m_SrcStart;
- return idx < m_dwWeightTablesSize ? &pWeight->m_Weights[idx] : nullptr;
+ return idx < GetPixelWeightSize() ? &pWeight->m_Weights[idx] : nullptr;
}
CStretchEngine::CStretchEngine(IFX_ScanlineComposer* pDestBitmap,
« no previous file with comments | « core/fxge/dib/dib_int.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698