Add comment for subtle code in CPDF_StreamContentParser
Handle_BeginImage() has a ByteStringView that needs to be processed
immediately and then not used again. Explain what is going on.
Change-Id: I4ff3aed5bdd0242d76532c68b5b87df06f354265
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/127851
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index cea665e..340f0d7 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -627,7 +627,8 @@
if (type != CPDF_StreamParser::ElementType::kName) {
break;
}
- auto word = m_pSyntax->GetWord();
+ // Next `m_pSyntax` read below may invalidate `word`. Must save to `key`.
+ ByteStringView word = m_pSyntax->GetWord();
ByteString key(word.Last(word.GetLength() - 1));
auto pObj = m_pSyntax->ReadNextObject(false, false, 0);
if (pObj && !pObj->IsInline()) {