summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Tox/src/tox_proto.cpp2
-rw-r--r--protocols/Tox/src/tox_utils.cpp19
2 files changed, 12 insertions, 9 deletions
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 73bed91d17..8961ed679b 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -121,7 +121,7 @@ int __cdecl CToxProto::SetStatus(int iNewStatus)
uint8_t *pub_key = HexToBinString(BOOTSTRAP_KEY);
res = tox_bootstrap_from_address(tox, BOOTSTRAP_ADDRESS, 0, htons(BOOTSTRAP_PORT), pub_key);
- //mir_free(pub_key);
+ mir_free(pub_key);
if (!res)
{
SetStatus(ID_STATUS_OFFLINE);
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp
index 093becbce4..3888da24bd 100644
--- a/protocols/Tox/src/tox_utils.cpp
+++ b/protocols/Tox/src/tox_utils.cpp
@@ -3,17 +3,20 @@
uint8_t *CToxProto::HexToBinString(char *hex_string)
{
// byte is represented by exactly 2 hex digits, so lenth of binary string
- // is half of that of the hex one. only hex string with even length
- // valid. the more proper implementation would be to check if strlen(hex_string)
- // is odd and return error code if it is. we assume strlen is even. if it's not
- // then the last byte just won't be written in 'ret'.
- size_t i, len = (strlen(hex_string) / 2);
- uint8_t *ret = (uint8_t*)mir_alloc(len);
+ // is half of that of the hex one. only hex string with even length valid.
+ // the more proper implementation would be to check if strlen(hex_string)
+ // is odd and return error code if it is. we assume strlen is even.
+ // if it's not then the last byte just won't be written in 'ret'.
+ int length = strlen(hex_string) / 2;
+ uint8_t *ret = (uint8_t*)mir_alloc(length);
char *pos = hex_string;
- for (i = 0; i < len; i++, pos += 2)
+ for (int i = 0; i < length; i++, pos += 2)
{
- sscanf(pos, "%2hhx", &ret[i]);
+ //sscanf(pos, "%2hhx", &ret[i]);
+ uint8_t byteval;
+ sscanf(pos, "%2hhx", &byteval);
+ ret[i] = byteval;
}
return ret;