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

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

Issue 2414473003: Handle undefined shifts in CPDF_PSEngine. (Closed)
Patch Set: self nit 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 d2e08a511c6566e583e9f7e29c0221058580ed1c..2efbdc24808f064928da8c7fca9e7606efa83505 100644
--- a/core/fpdfapi/page/fpdf_page_func.cpp
+++ b/core/fpdfapi/page/fpdf_page_func.cpp
@@ -343,11 +343,20 @@ FX_BOOL CPDF_PSEngine::DoOperator(PDF_PSOP op) {
case PSOP_BITSHIFT: {
int shift = (int)Pop();
int i = (int)Pop();
- if (shift > 0) {
- Push(i << shift);
- } else {
- Push(i >> -shift);
+ if (shift == 0) {
+ Push(i);
+ break;
+ }
+ if (shift < -31 || shift > 31) {
+ Push(0);
+ break;
}
+ uint64_t unsigned_i = i;
Tom Sepez 2016/10/20 20:55:29 think we want to do it as a signed64?
+ if (shift > 0)
+ unsigned_i <<= shift;
+ else
+ unsigned_i >>= shift;
Tom Sepez 2016/10/20 20:55:30 need a -shift here?
+ Push(static_cast<int>(unsigned_i & 0xFFFFFFFF));
break;
}
case PSOP_TRUE:
« 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