diff options
author | thestig <thestig@chromium.org> | 2016-06-23 19:57:45 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-06-23 19:57:45 -0700 |
commit | 29d447ae35101675a2a2d8bc1dcfca65de7f3929 (patch) | |
tree | 6a84b11413a53fb547e242bea6a5ddf55df7293a /core/fpdfapi/fpdf_page | |
parent | ce56557ef58facf2519f541d5cad33ea121b4c21 (diff) | |
download | pdfium-29d447ae35101675a2a2d8bc1dcfca65de7f3929.tar.xz |
Improve hint table validation checks.
Check required hint table dictionary entries and make sure they:
- Exist.
- Are of the right type.
Along the way:
- Fix FX_atonum() to not have a non-const pass-by-ref param.
- Simplify code in CPDF_StreamContentParser.
- Make CPDF_Number::IsInteger() a const method.
BUG=610555
Review-Url: https://codereview.chromium.org/2095763003
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r-- | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 42 | ||||
-rw-r--r-- | core/fpdfapi/fpdf_page/pageint.h | 2 |
2 files changed, 22 insertions, 22 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 802f424274..0d16994bbe 100644 --- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -274,35 +274,36 @@ int CPDF_StreamContentParser::GetNextParamPos() { void CPDF_StreamContentParser::AddNameParam(const FX_CHAR* name, int len) { CFX_ByteStringC bsName(name, len); - int index = GetNextParamPos(); + ContentParam& param = m_ParamBuf[GetNextParamPos()]; if (len > 32) { - m_ParamBuf[index].m_Type = ContentParam::OBJECT; - m_ParamBuf[index].m_pObject = new CPDF_Name(PDF_NameDecode(bsName)); + param.m_Type = ContentParam::OBJECT; + param.m_pObject = new CPDF_Name(PDF_NameDecode(bsName)); } else { - m_ParamBuf[index].m_Type = ContentParam::NAME; + param.m_Type = ContentParam::NAME; if (bsName.Find('#') == -1) { - FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, name, len); - m_ParamBuf[index].m_Name.m_Len = len; + FXSYS_memcpy(param.m_Name.m_Buffer, name, len); + param.m_Name.m_Len = len; } else { CFX_ByteString str = PDF_NameDecode(bsName); - FXSYS_memcpy(m_ParamBuf[index].m_Name.m_Buffer, str.c_str(), - str.GetLength()); - m_ParamBuf[index].m_Name.m_Len = str.GetLength(); + FXSYS_memcpy(param.m_Name.m_Buffer, str.c_str(), str.GetLength()); + param.m_Name.m_Len = str.GetLength(); } } } void CPDF_StreamContentParser::AddNumberParam(const FX_CHAR* str, int len) { - int index = GetNextParamPos(); - m_ParamBuf[index].m_Type = ContentParam::NUMBER; - FX_atonum(CFX_ByteStringC(str, len), m_ParamBuf[index].m_Number.m_bInteger, - &m_ParamBuf[index].m_Number.m_Integer); + ContentParam& param = m_ParamBuf[GetNextParamPos()]; + param.m_Type = ContentParam::NUMBER; + param.m_Number.m_bInteger = + FX_atonum(CFX_ByteStringC(str, len), ¶m.m_Number.m_Integer); } + void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) { - int index = GetNextParamPos(); - m_ParamBuf[index].m_Type = ContentParam::OBJECT; - m_ParamBuf[index].m_pObject = pObj; + ContentParam& param = m_ParamBuf[GetNextParamPos()]; + param.m_Type = ContentParam::OBJECT; + param.m_pObject = pObj; } + void CPDF_StreamContentParser::ClearAllParams() { uint32_t index = m_ParamStartPos; for (uint32_t i = 0; i < m_ParamCount; i++) { @@ -1601,14 +1602,13 @@ void CPDF_StreamContentParser::ParsePathObject() { break; } case CPDF_StreamParser::Number: { - if (nParams == 6) { + if (nParams == 6) break; - } - FX_BOOL bInteger; + int value; - FX_atonum( + bool bInteger = FX_atonum( CFX_ByteStringC(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize()), - bInteger, &value); + &value); params[nParams++] = bInteger ? (FX_FLOAT)value : *(FX_FLOAT*)&value; break; } diff --git a/core/fpdfapi/fpdf_page/pageint.h b/core/fpdfapi/fpdf_page/pageint.h index 29fd6fb86e..08cfd0472a 100644 --- a/core/fpdfapi/fpdf_page/pageint.h +++ b/core/fpdfapi/fpdf_page/pageint.h @@ -87,7 +87,7 @@ struct ContentParam { Type m_Type; union { struct { - FX_BOOL m_bInteger; + bool m_bInteger; union { int m_Integer; FX_FLOAT m_Float; |