summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Base/ByteArray.h8
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp1
-rw-r--r--Swiften/StringCodecs/SHA1.cpp6
3 files changed, 12 insertions, 3 deletions
diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h
index 9e7a928..d55da1f 100644
--- a/Swiften/Base/ByteArray.h
+++ b/Swiften/Base/ByteArray.h
@@ -139,6 +139,14 @@ namespace Swift {
static std::vector<unsigned char> create(const unsigned char* c, size_t n);
static std::vector<unsigned char> create(const char* c, size_t n);
+ static const unsigned char* data(const std::vector<unsigned char>& v) {
+ return v.empty() ? NULL : &v[0];
+ }
+
+ static const char* charData(const std::vector<unsigned char>& v) {
+ return v.empty() ? NULL : reinterpret_cast<const char*>(&v[0]);
+ }
+
private:
std::vector<unsigned char> data_;
};
diff --git a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
index 88d9cd4..590443f 100644
--- a/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBReceiveSessionTest.cpp
@@ -34,6 +34,7 @@ class IBBReceiveSessionTest : public CppUnit::TestFixture {
void setUp() {
stanzaChannel = new DummyStanzaChannel();
iqRouter = new IQRouter(stanzaChannel);
+ finished = false;
}
void tearDown() {
diff --git a/Swiften/StringCodecs/SHA1.cpp b/Swiften/StringCodecs/SHA1.cpp
index a78a7b0..2703796 100644
--- a/Swiften/StringCodecs/SHA1.cpp
+++ b/Swiften/StringCodecs/SHA1.cpp
@@ -185,7 +185,7 @@ SHA1::SHA1() {
SHA1& SHA1::update(const std::vector<unsigned char>& input) {
std::vector<unsigned char> inputCopy(input);
- Update(&context, (boost::uint8_t*) &inputCopy[0], inputCopy.size());
+ Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
return *this;
}
@@ -193,7 +193,7 @@ std::vector<unsigned char> SHA1::getHash() const {
std::vector<unsigned char> digest;
digest.resize(20);
CTX contextCopy(context);
- Final((boost::uint8_t*) &digest[0], &contextCopy);
+ Final((boost::uint8_t*) ByteArray::data(digest), &contextCopy);
return digest;
}
@@ -202,7 +202,7 @@ ByteArray SHA1::getHash(const ByteArray& input) {
Init(&context);
std::vector<unsigned char> inputCopy(input.getVector());
- Update(&context, (boost::uint8_t*) &inputCopy[0], inputCopy.size());
+ Update(&context, (boost::uint8_t*) ByteArray::data(inputCopy), inputCopy.size());
ByteArray digest;
digest.resize(20);