summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.cpp5
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.cpp12
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp3
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp7
-rw-r--r--core/fpdfapi/parser/fpdf_parser_decode.cpp4
5 files changed, 15 insertions, 16 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.cpp b/core/fpdfapi/edit/cpdf_creator.cpp
index db5bd681d4..e31da13a4d 100644
--- a/core/fpdfapi/edit/cpdf_creator.cpp
+++ b/core/fpdfapi/edit/cpdf_creator.cpp
@@ -184,10 +184,7 @@ bool CPDF_Creator::WriteStream(const CPDF_Object* pStream,
return false;
}
- if (!m_Archive->WriteString("\r\nendstream"))
- return false;
-
- return true;
+ return m_Archive->WriteString("\r\nendstream");
}
bool CPDF_Creator::WriteIndirectObj(uint32_t objnum, const CPDF_Object* pObj) {
diff --git a/core/fpdfapi/page/cpdf_streamparser.cpp b/core/fpdfapi/page/cpdf_streamparser.cpp
index aa1d227de0..2c7e0256f5 100644
--- a/core/fpdfapi/page/cpdf_streamparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamparser.cpp
@@ -499,7 +499,13 @@ ByteString CPDF_StreamParser::ReadString() {
status = 2;
break;
}
- if (ch == 'n') {
+ if (ch == '\r') {
+ status = 4;
+ break;
+ }
+ if (ch == '\n') {
+ // Do nothing.
+ } else if (ch == 'n') {
buf << '\n';
} else if (ch == 'r') {
buf << '\r';
@@ -509,10 +515,6 @@ ByteString CPDF_StreamParser::ReadString() {
buf << '\b';
} else if (ch == 'f') {
buf << '\f';
- } else if (ch == '\r') {
- status = 4;
- break;
- } else if (ch == '\n') {
} else {
buf << static_cast<char>(ch);
}
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 5b57b949ba..4e77773a3b 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -394,9 +394,8 @@ bool CPDF_Parser::VerifyCrossRefV4() {
// If the object number read doesn't match the one stored,
// something is wrong with the cross reference table.
return false;
- } else {
- return true;
}
+ return true;
}
return true;
}
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index ddf420b34a..66ce1838f2 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -208,6 +208,10 @@ ByteString CPDF_SyntaxParser::ReadString() {
break;
}
+ if (ch == '\r') {
+ status = ReadStatus::CarriageReturn;
+ break;
+ }
if (ch == 'n') {
buf << '\n';
} else if (ch == 'r') {
@@ -218,9 +222,6 @@ ByteString CPDF_SyntaxParser::ReadString() {
buf << '\b';
} else if (ch == 'f') {
buf << '\f';
- } else if (ch == '\r') {
- status = ReadStatus::CarriageReturn;
- break;
} else if (ch != '\n') {
buf << static_cast<char>(ch);
}
diff --git a/core/fpdfapi/parser/fpdf_parser_decode.cpp b/core/fpdfapi/parser/fpdf_parser_decode.cpp
index 9532b8242d..3a8660f0a4 100644
--- a/core/fpdfapi/parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/parser/fpdf_parser_decode.cpp
@@ -361,6 +361,8 @@ bool PDF_DataDecode(const uint8_t* src_buf,
uint8_t* new_buf = nullptr;
uint32_t new_size = 0xFFFFFFFF;
int offset = -1;
+ if (decoder == "Crypt")
+ continue;
if (decoder == "FlateDecode" || decoder == "Fl") {
if (bImageAcc && i == nSize - 1) {
*ImageEncoding = "FlateDecode";
@@ -387,8 +389,6 @@ bool PDF_DataDecode(const uint8_t* src_buf,
return true;
}
offset = RunLengthDecode(last_buf, last_size, &new_buf, &new_size);
- } else if (decoder == "Crypt") {
- continue;
} else {
// If we get here, assume it's an image decoder.
if (decoder == "DCT")