OLD | NEW |
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/xml/fde_xml_imp.h" | 7 #include "xfa/fde/xml/fde_xml_imp.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 m_iCurrentPos = m_pStream->GetBOM(bom); | 1307 m_iCurrentPos = m_pStream->GetBOM(bom); |
1308 ASSERT(!m_pBuffer); | 1308 ASSERT(!m_pBuffer); |
1309 | 1309 |
1310 FX_SAFE_INT32 alloc_size_safe = m_iXMLPlaneSize; | 1310 FX_SAFE_INT32 alloc_size_safe = m_iXMLPlaneSize; |
1311 alloc_size_safe += 1; // For NUL. | 1311 alloc_size_safe += 1; // For NUL. |
1312 if (!alloc_size_safe.IsValid() || alloc_size_safe.ValueOrDie() <= 0) { | 1312 if (!alloc_size_safe.IsValid() || alloc_size_safe.ValueOrDie() <= 0) { |
1313 m_syntaxParserResult = FDE_XmlSyntaxResult::Error; | 1313 m_syntaxParserResult = FDE_XmlSyntaxResult::Error; |
1314 return; | 1314 return; |
1315 } | 1315 } |
1316 | 1316 |
1317 m_pBuffer = FX_Alloc(FX_WCHAR, alloc_size_safe.ValueOrDie()); | 1317 m_pBuffer = FX_Alloc(FX_WCHAR, alloc_size_safe.ValueOrDie<size_t>()); |
1318 m_pStart = m_pEnd = m_pBuffer; | 1318 m_pStart = m_pEnd = m_pBuffer; |
1319 ASSERT(!m_BlockBuffer.IsInitialized()); | 1319 ASSERT(!m_BlockBuffer.IsInitialized()); |
1320 m_BlockBuffer.InitBuffer(); | 1320 m_BlockBuffer.InitBuffer(); |
1321 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); | 1321 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); |
1322 m_iParsedBytes = m_iParsedChars = 0; | 1322 m_iParsedBytes = m_iParsedChars = 0; |
1323 m_iBufferChars = 0; | 1323 m_iBufferChars = 0; |
1324 } | 1324 } |
1325 | 1325 |
1326 FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { | 1326 FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() { |
1327 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || | 1327 if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error || |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, false); | 1914 m_BlockBuffer.DeleteTextChars(m_iDataLength - m_iEntityStart, false); |
1915 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); | 1915 m_pCurrentBlock = m_BlockBuffer.GetAvailableBlock(m_iIndexInBlock); |
1916 m_iEntityStart = -1; | 1916 m_iEntityStart = -1; |
1917 } else { | 1917 } else { |
1918 if (m_iEntityStart < 0 && character == L'&') { | 1918 if (m_iEntityStart < 0 && character == L'&') { |
1919 m_iEntityStart = m_iDataLength - 1; | 1919 m_iEntityStart = m_iDataLength - 1; |
1920 } | 1920 } |
1921 } | 1921 } |
1922 m_pStart++; | 1922 m_pStart++; |
1923 } | 1923 } |
OLD | NEW |