summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/fpdf_page_func.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp
index bf44a1e7c5..6af787ea49 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];