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

Side by Side Diff: xfa/fde/css/fde_cssdatatable.cpp

Issue 2535663003: Fix crash in CFDE_CSSSyntaxParser when parsing empty url (Closed)
Patch Set: Comments Created 4 years 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 unified diff | Download patch
« no previous file with comments | « xfa/fde/css/fde_cssdatatable.h ('k') | xfa/fde/css/fde_cssdeclaration.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fde/css/fde_cssdatatable.h" 7 #include "xfa/fde/css/fde_cssdatatable.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "xfa/fgas/crt/fgas_codepage.h" 10 #include "xfa/fgas/crt/fgas_codepage.h"
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 FDE_LPCCSSLENGTHUNITTABLE pUnit = 691 FDE_LPCCSSLENGTHUNITTABLE pUnit =
692 FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2)); 692 FDE_GetCSSLengthUnitByName(CFX_WideStringC(pszValue, 2));
693 if (pUnit) 693 if (pUnit)
694 eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue; 694 eUnit = (FDE_CSSPRIMITIVETYPE)pUnit->wValue;
695 } 695 }
696 return true; 696 return true;
697 } 697 }
698 698
699 bool FDE_ParseCSSString(const FX_WCHAR* pszValue, 699 bool FDE_ParseCSSString(const FX_WCHAR* pszValue,
700 int32_t iValueLen, 700 int32_t iValueLen,
701 int32_t& iOffset, 701 int32_t* iOffset,
702 int32_t& iLength) { 702 int32_t* iLength) {
703 ASSERT(pszValue && iValueLen > 0); 703 ASSERT(pszValue && iValueLen > 0);
704 iOffset = 0; 704 *iOffset = 0;
705 iLength = iValueLen; 705 *iLength = iValueLen;
706 if (iValueLen >= 2) { 706 if (iValueLen >= 2) {
707 FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1]; 707 FX_WCHAR first = pszValue[0], last = pszValue[iValueLen - 1];
708 if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) { 708 if ((first == '\"' && last == '\"') || (first == '\'' && last == '\'')) {
709 iOffset = 1, iLength -= 2; 709 *iOffset = 1;
710 *iLength -= 2;
710 } 711 }
711 } 712 }
712 return iValueLen > 0; 713 return iValueLen > 0;
713 } 714 }
714 715
715 bool FDE_ParseCSSURI(const FX_WCHAR* pszValue, 716 bool FDE_ParseCSSURI(const FX_WCHAR* pszValue,
716 int32_t iValueLen, 717 int32_t* iOffset,
717 int32_t& iOffset, 718 int32_t* iLength) {
718 int32_t& iLength) { 719 ASSERT(pszValue && *iLength > 0);
719 ASSERT(pszValue && iValueLen > 0); 720 if (*iLength < 6 || pszValue[*iLength - 1] != ')' ||
720 if (iValueLen < 6 || pszValue[iValueLen - 1] != ')' ||
721 FXSYS_wcsnicmp(L"url(", pszValue, 4)) { 721 FXSYS_wcsnicmp(L"url(", pszValue, 4)) {
722 return false; 722 return false;
723 } 723 }
724 if (FDE_ParseCSSString(pszValue + 4, iValueLen - 5, iOffset, iLength)) { 724 if (FDE_ParseCSSString(pszValue + 4, *iLength - 5, iOffset, iLength)) {
725 iOffset += 4; 725 *iOffset += 4;
726 return true; 726 return true;
727 } 727 }
728 return false; 728 return false;
729 } 729 }
730 730
731 bool FDE_ParseCSSColor(const FX_WCHAR* pszValue, 731 bool FDE_ParseCSSColor(const FX_WCHAR* pszValue,
732 int32_t iValueLen, 732 int32_t iValueLen,
733 FX_ARGB& dwColor) { 733 FX_ARGB& dwColor) {
734 ASSERT(pszValue && iValueLen > 0); 734 ASSERT(pszValue && iValueLen > 0);
735 735
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 960
961 int32_t CFDE_CSSPrimitiveValue::CountArgs() const { 961 int32_t CFDE_CSSPrimitiveValue::CountArgs() const {
962 ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); 962 ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function);
963 return m_pFunction->CountArgs(); 963 return m_pFunction->CountArgs();
964 } 964 }
965 965
966 IFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const { 966 IFDE_CSSValue* CFDE_CSSPrimitiveValue::GetArgs(int32_t index) const {
967 ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function); 967 ASSERT(m_eType == FDE_CSSPRIMITIVETYPE_Function);
968 return m_pFunction->GetArgs(index); 968 return m_pFunction->GetArgs(index);
969 } 969 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssdatatable.h ('k') | xfa/fde/css/fde_cssdeclaration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698