summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/ExpatParser.cpp')
-rw-r--r--Swiften/Parser/ExpatParser.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp
index 77d959c..8415c42 100644
--- a/Swiften/Parser/ExpatParser.cpp
+++ b/Swiften/Parser/ExpatParser.cpp
@@ -1,25 +1,24 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/Parser/ExpatParser.h>
#include <cassert>
+#include <limits>
#include <memory>
#include <string>
#include <expat.h>
-#include <boost/numeric/conversion/cast.hpp>
-
#include <Swiften/Base/String.h>
#include <Swiften/Parser/XMLParserClient.h>
#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
namespace Swift {
static const char NAMESPACE_SEPARATOR = '\x01';
@@ -78,19 +77,22 @@ ExpatParser::ExpatParser(XMLParserClient* client) : XMLParser(client), p(new Pri
XML_SetXmlDeclHandler(p->parser_, handleXMLDeclaration);
XML_SetEntityDeclHandler(p->parser_, handleEntityDeclaration);
}
ExpatParser::~ExpatParser() {
XML_ParserFree(p->parser_);
}
bool ExpatParser::parse(const std::string& data) {
- bool success = XML_Parse(p->parser_, data.c_str(), boost::numeric_cast<int>(data.size()), false) == XML_STATUS_OK;
+ if (data.size() > std::numeric_limits<int>::max()) {
+ return false;
+ }
+ bool success = XML_Parse(p->parser_, data.c_str(), static_cast<int>(data.size()), false) == XML_STATUS_OK;
/*if (!success) {
std::cout << "ERROR: " << XML_ErrorString(XML_GetErrorCode(p->parser_)) << " while parsing " << data << std::endl;
}*/
return success;
}
void ExpatParser::stopParser() {
XML_StopParser(p->parser_, static_cast<XML_Bool>(0));
}