XML: fixed an issue with parsing a memory buffer > 2 GB
This commit is contained in:
Родитель
a6f8d07757
Коммит
9666e37317
|
@ -265,7 +265,15 @@ void ParserEngine::parse(const char* pBuffer, std::size_t size)
|
|||
pushContext(_parser, &src);
|
||||
if (_pContentHandler) _pContentHandler->setDocumentLocator(this);
|
||||
if (_pContentHandler) _pContentHandler->startDocument();
|
||||
if (!XML_Parse(_parser, pBuffer, static_cast<int>(size), 1))
|
||||
std::size_t processed = 0;
|
||||
while (processed < size)
|
||||
{
|
||||
const int bufferSize = processed + PARSE_BUFFER_SIZE < size ? PARSE_BUFFER_SIZE : size - processed;
|
||||
if (!XML_Parse(_parser, pBuffer + processed, bufferSize, 0))
|
||||
handleError(XML_GetErrorCode(_parser));
|
||||
processed += bufferSize;
|
||||
}
|
||||
if (!XML_Parse(_parser, pBuffer+processed, 0, 1))
|
||||
handleError(XML_GetErrorCode(_parser));
|
||||
if (_pContentHandler) _pContentHandler->endDocument();
|
||||
popContext();
|
||||
|
|
Загрузка…
Ссылка в новой задаче