diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-06-03 11:09:08 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-06-03 11:09:08 (GMT) |
commit | 10334c139670861d4860da59ad837fc3fe6fd41e (patch) | |
tree | b632360747e635e229f336760ccc76789797a8bf /Swiften/Base | |
parent | 8189054fca9c68194ffc328eb7beecf241bbbcd7 (diff) | |
download | swift-contrib-10334c139670861d4860da59ad837fc3fe6fd41e.zip swift-contrib-10334c139670861d4860da59ad837fc3fe6fd41e.tar.bz2 |
Ensure safety on onDataRead and onDataWritten signals.
Diffstat (limited to 'Swiften/Base')
-rw-r--r-- | Swiften/Base/SafeByteArray.h | 6 | ||||
-rw-r--r-- | Swiften/Base/SafeString.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Swiften/Base/SafeByteArray.h b/Swiften/Base/SafeByteArray.h index 832b116..2f3fbfa 100644 --- a/Swiften/Base/SafeByteArray.h +++ b/Swiften/Base/SafeByteArray.h @@ -39,5 +39,11 @@ namespace Swift { } SafeByteArray createSafeByteArray(const SafeString& s); + + /* WARNING! This breaks the safety of the data in the safe byte array. + * Do not use in modes that require data safety. */ + inline std::string safeByteArrayToString(const SafeByteArray& b) { + return byteArrayToString(ByteArray(b.begin(), b.end())); + } } diff --git a/Swiften/Base/SafeString.h b/Swiften/Base/SafeString.h index bb6d6c7..d549bd1 100644 --- a/Swiften/Base/SafeString.h +++ b/Swiften/Base/SafeString.h @@ -26,6 +26,8 @@ namespace Swift { SafeString(const char*); + SafeString(const char* begin, const char* end) : data(begin, end) { + } std::string toString() const { return data.empty() ? std::string() : std::string(&data[0], data.size()); |