No need to buffer CSS comments Instead of looking for a slash and then looking behind for a star in the output buffer, look for a star then look ahead for a slash. Change-Id: I16ec56af8eeb27a972faebe08e34a11dad24d10f Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/66375 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/css/cfx_csssyntaxparser.cpp b/core/fxcrt/css/cfx_csssyntaxparser.cpp index eb32297..8c92de4 100644 --- a/core/fxcrt/css/cfx_csssyntaxparser.cpp +++ b/core/fxcrt/css/cfx_csssyntaxparser.cpp
@@ -159,11 +159,9 @@ } break; case SyntaxMode::kComment: - if (wch == '/' && m_Output.GetLength() > 0 && - m_Output.GetBuffer()[m_Output.GetLength() - 1] == '*') { + if (wch == '*' && m_Input.GetNextChar() == '/') { RestoreMode(); - } else { - m_Output.AppendChar(wch); + m_Input.MoveNext(); } m_Input.MoveNext(); break;