diff options
author | Edwin Mons <edwin.mons@isode.com> | 2018-11-09 10:03:50 (GMT) |
---|---|---|
committer | Edwin Mons <edwin.mons@isode.com> | 2018-11-14 14:17:46 (GMT) |
commit | c7ad127218e3901e0006e75aa7e1399b449a845e (patch) | |
tree | 4371fe826528a5ad08cc036a09b375b51dfdce32 /Swiften | |
parent | 5d7fc97148125584a44a39a4beee1e71d9518385 (diff) | |
download | swift-c7ad127218e3901e0006e75aa7e1399b449a845e.zip swift-c7ad127218e3901e0006e75aa7e1399b449a845e.tar.bz2 |
Remove numeric_casts from BOSH parser
The two uses of numeric_casts have been rewritten as static casts, with
asserts to guarantee (and inform the developer) that the number is never
negative (code inspection showed that this should never be the case).
Test-Information:
Unit tests pass on macOS and Debian
Change-Id: I3ca63724721ecd8e351d9017e0975b6ae326f85f
Diffstat (limited to 'Swiften')
-rw-r--r-- | Swiften/Parser/BOSHBodyExtractor.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Swiften/Parser/BOSHBodyExtractor.cpp b/Swiften/Parser/BOSHBodyExtractor.cpp index c45d338..ff56792 100644 --- a/Swiften/Parser/BOSHBodyExtractor.cpp +++ b/Swiften/Parser/BOSHBodyExtractor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016 Isode Limited. + * Copyright (c) 2011-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -8,8 +8,6 @@ #include <memory> -#include <boost/numeric/conversion/cast.hpp> - #include <Swiften/Parser/XMLParser.h> #include <Swiften/Parser/XMLParserClient.h> #include <Swiften/Parser/XMLParserFactory.h> @@ -119,17 +117,19 @@ BOSHBodyExtractor::BOSHBodyExtractor(XMLParserFactory* parserFactory, const Byte body = BOSHBody(); if (!endElementSeen) { + assert(i <= j.base()); body->content = std::string( reinterpret_cast<const char*>(vecptr(data) + std::distance(data.begin(), i)), - boost::numeric_cast<size_t>(std::distance(i, j.base()))); + static_cast<size_t>(std::distance(i, j.base()))); } // Parse the body element BOSHBodyParserClient parserClient(this); std::shared_ptr<XMLParser> parser(parserFactory->createXMLParser(&parserClient)); + assert(data.begin() <= i); if (!parser->parse(std::string( reinterpret_cast<const char*>(vecptr(data)), - boost::numeric_cast<size_t>(std::distance(data.begin(), i))))) { + static_cast<size_t>(std::distance(data.begin(), i))))) { /* TODO: This needs to be only validating the BOSH <body> element, so that XMPP parsing errors are caught at the correct higher layer */ body = boost::optional<BOSHBody>(); |