diff options
author | lloyd <[email protected]> | 2011-04-29 16:59:29 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2011-04-29 16:59:29 +0000 |
commit | 93b5927837b75d9660084e83adf04c77a57fe4b3 (patch) | |
tree | e3946d10e67182cb5901a217ef1ccc90048b025e /src/codec | |
parent | 96043ac4c4fdd4e7c23143097922843552b4aa9a (diff) |
Calling &str[str.size()] is only valid if str is const; otherwise the
results are undefined. This happens to work under GCC and most other
compilers, but does not under Visual C++ 2010. This broke hex_encode
when encoding an empty input, and this subsequently broke SSL
handshaking.
2010 includes a TR1 that works fine for SSL, but it puts the headers
in the main header space rather than under tr1/, so account for that.
Hack the socket header into working under WinSock
Tick version to 1.10.0
Diffstat (limited to 'src/codec')
-rw-r--r-- | src/codec/hex/hex.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/codec/hex/hex.cpp b/src/codec/hex/hex.cpp index 49d6e7190..41ba1298d 100644 --- a/src/codec/hex/hex.cpp +++ b/src/codec/hex/hex.cpp @@ -37,9 +37,7 @@ void hex_encode(char output[], std::string hex_encode(const MemoryRegion<byte>& input, bool uppercase) { - return hex_encode(&input[0], - input.size(), - uppercase); + return hex_encode(&input[0], input.size(), uppercase); } std::string hex_encode(const byte input[], @@ -47,7 +45,10 @@ std::string hex_encode(const byte input[], bool uppercase) { std::string output(2 * input_length, 0); - hex_encode(&output[0], input, input_length, uppercase); + + if(input_length) + hex_encode(&output[0], input, input_length, uppercase); + return output; } |