summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp39
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h7
2 files changed, 15 insertions, 31 deletions
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 20892cc264..0760e150f3 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -318,21 +318,9 @@ int CPDF_StreamContentParser::GetNextParamPos() {
void CPDF_StreamContentParser::AddNameParam(const ByteStringView& bsName) {
ContentParam& param = m_ParamBuf[GetNextParamPos()];
- if (bsName.GetLength() > 32) {
- param.m_Type = ContentParam::OBJECT;
- param.m_pObject = pdfium::MakeUnique<CPDF_Name>(
- m_pDocument->GetByteStringPool(), PDF_NameDecode(bsName));
- } else {
- param.m_Type = ContentParam::NAME;
- if (bsName.Contains('#')) {
- ByteString str = PDF_NameDecode(bsName);
- memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength());
- param.m_Name.m_Len = str.GetLength();
- } else {
- memcpy(param.m_Name.m_Buffer, bsName.raw_str(), bsName.GetLength());
- param.m_Name.m_Len = bsName.GetLength();
- }
- }
+ param.m_Type = ContentParam::NAME;
+ param.m_Name =
+ bsName.Contains('#') ? PDF_NameDecode(bsName) : ByteString(bsName);
}
void CPDF_StreamContentParser::AddNumberParam(const ByteStringView& str) {
@@ -381,8 +369,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
if (param.m_Type == ContentParam::NAME) {
param.m_Type = ContentParam::OBJECT;
param.m_pObject = pdfium::MakeUnique<CPDF_Name>(
- m_pDocument->GetByteStringPool(),
- ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len));
+ m_pDocument->GetByteStringPool(), param.m_Name);
return param.m_pObject.get();
}
if (param.m_Type == ContentParam::OBJECT)
@@ -393,20 +380,20 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) {
}
ByteString CPDF_StreamContentParser::GetString(uint32_t index) const {
- if (index >= m_ParamCount) {
+ if (index >= m_ParamCount)
return ByteString();
- }
+
int real_index = m_ParamStartPos + m_ParamCount - index - 1;
- if (real_index >= kParamBufSize) {
+ if (real_index >= kParamBufSize)
real_index -= kParamBufSize;
- }
+
const ContentParam& param = m_ParamBuf[real_index];
- if (param.m_Type == ContentParam::NAME) {
- return ByteString(param.m_Name.m_Buffer, param.m_Name.m_Len);
- }
- if (param.m_Type == 0 && param.m_pObject) {
+ if (param.m_Type == ContentParam::NAME)
+ return param.m_Name;
+
+ if (param.m_Type == 0 && param.m_pObject)
return param.m_pObject->GetString();
- }
+
return ByteString();
}
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 6417043305..d9239fd6fa 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -71,12 +71,9 @@ class CPDF_StreamContentParser {
~ContentParam();
Type m_Type;
- std::unique_ptr<CPDF_Object> m_pObject;
FX_Number m_Number;
- struct {
- int m_Len;
- char m_Buffer[32];
- } m_Name;
+ ByteString m_Name;
+ std::unique_ptr<CPDF_Object> m_pObject;
};
static const int kParamBufSize = 16;