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

Unified Diff: core/fpdfapi/page/fpdf_page_func.cpp

Issue 2412833002: Optimize roll operator in CPDF_PSEngine. (Closed)
Patch Set: Created 4 years, 2 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: core/fpdfapi/page/fpdf_page_func.cpp
diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp
index bf44a1e7c5666b49f9a3c4faff099c240ebf7018..6af787ea4977f6e57d9721ea24f9ac8fc0e68548 100644
--- a/core/fpdfapi/page/fpdf_page_func.cpp
+++ b/core/fpdfapi/page/fpdf_page_func.cpp
@@ -376,10 +376,12 @@ FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) {
case PSOP_ROLL: {
int j = static_cast<int>(Pop());
int n = static_cast<int>(Pop());
- if (m_StackCount == 0)
+ if (j == 0 || n == 0 || m_StackCount == 0)
break;
if (n < 0 || n > static_cast<int>(m_StackCount))
break;
+
+ j %= n;
if (j < 0) {
for (int i = 0; i < -j; i++) {
FX_FLOAT first = m_Stack[m_StackCount - n];
« 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