Skip to content

Commit

Permalink
Avoid pointer arithmetic in cpdf_streamparser.cpp
Browse files Browse the repository at this point in the history
-- use GetWord() helper method.

Change-Id: I3981f6524a6cbf4c918c393220728323e84ea075
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/96953
Commit-Queue: Tom Sepez <[email protected]>
Reviewed-by: Lei Zhang <[email protected]>
  • Loading branch information
tsepez authored and Pdfium LUCI CQ committed Aug 29, 2022
1 parent 7fa6832 commit c9c2180
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions core/fpdfapi/page/cpdf_streamparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,12 @@ RetainPtr<CPDF_Object> CPDF_StreamParser::ReadNextObject(

if (bIsNumber) {
m_WordBuffer[m_WordSize] = 0;
return pdfium::MakeRetain<CPDF_Number>(
ByteStringView(m_WordBuffer, m_WordSize));
return pdfium::MakeRetain<CPDF_Number>(GetWord());
}

int first_char = m_WordBuffer[0];
if (first_char == '/') {
ByteString name =
PDF_NameDecode(ByteStringView(m_WordBuffer + 1, m_WordSize - 1));
ByteString name = PDF_NameDecode(GetWord().Substr(1));
return pdfium::MakeRetain<CPDF_Name>(m_pPool, name);
}

Expand All @@ -338,8 +336,7 @@ RetainPtr<CPDF_Object> CPDF_StreamParser::ReadNextObject(
if (!m_WordSize || m_WordBuffer[0] != '/')
return nullptr;

ByteString key =
PDF_NameDecode(ByteStringView(m_WordBuffer + 1, m_WordSize - 1));
ByteString key = PDF_NameDecode(GetWord().Substr(1));
RetainPtr<CPDF_Object> pObj =
ReadNextObject(true, bInArray, dwRecursionLevel + 1);
if (!pObj)
Expand Down

0 comments on commit c9c2180

Please sign in to comment.