Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: xfa/fde/css/fde_csssyntax.cpp

Issue 2535663003: Fix crash in CFDE_CSSSyntaxParser when parsing empty url (Closed)
Patch Set: Comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « xfa/fde/css/fde_cssdeclaration.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fde/css/fde_csssyntax.cpp
diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp
index 436a94b67ba9e74108e3307ba7aed5e742d1c548..27094e1376641c69e8afa8f6be9533f180275498 100644
--- a/xfa/fde/css/fde_csssyntax.cpp
+++ b/xfa/fde/css/fde_csssyntax.cpp
@@ -6,6 +6,8 @@
#include "xfa/fde/css/fde_csssyntax.h"
+#include <algorithm>
+
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -280,16 +282,13 @@ FDE_CSSSYNTAXSTATUS CFDE_CSSSyntaxParser::DoSyntaxParse() {
if (wch <= ' ' || wch == ';') {
int32_t iURIStart, iURILength = m_TextData.GetLength();
- if (iURILength > 0 &&
- FDE_ParseCSSURI(m_TextData.GetBuffer(), iURILength, iURIStart,
- iURILength)) {
+ if (iURILength > 0 && FDE_ParseCSSURI(m_TextData.GetBuffer(),
+ &iURIStart, &iURILength)) {
m_TextData.Subtract(iURIStart, iURILength);
SwitchMode(FDE_CSSSYNTAXMODE_MediaType);
- if (IsImportEnabled()) {
+ if (IsImportEnabled())
return FDE_CSSSYNTAXSTATUS_URI;
- } else {
- break;
- }
+ break;
}
}
AppendChar(wch);
@@ -468,15 +467,10 @@ bool CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
m_iBufLen = iDesiredSize;
return true;
}
+
void CFDE_CSSTextBuf::Subtract(int32_t iStart, int32_t iLength) {
- ASSERT(iStart >= 0 && iLength > 0);
- if (iLength > m_iDatLen - iStart) {
- iLength = m_iDatLen - iStart;
- }
- if (iLength < 0) {
- iLength = 0;
- } else {
- FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR));
- }
+ ASSERT(iStart >= 0 && iLength >= 0);
+ iLength = std::max(std::min(iLength, m_iDatLen - iStart), 0);
+ FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR));
m_iDatLen = iLength;
}
« no previous file with comments | « xfa/fde/css/fde_cssdeclaration.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698