Commit 475992f1 authored by Ian Craggs's avatar Ian Craggs

Merge branch 'fixes' into develop

parents 0c0b7661 04a7b562
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* Ian Craggs - fix for bug 479376 * Ian Craggs - fix for bug 479376
* Ian Craggs - SNI support * Ian Craggs - SNI support
* Ian Craggs - fix for issue #164 * Ian Craggs - fix for issue #164
* Ian Craggs - fix for issue #179
*******************************************************************************/ *******************************************************************************/
/** /**
...@@ -57,7 +58,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port) ...@@ -57,7 +58,7 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
colon_pos = NULL; /* means it was an IPv6 separator, not for host:port */ colon_pos = NULL; /* means it was an IPv6 separator, not for host:port */
} }
if (colon_pos) if (colon_pos) /* have to strip off the port */
{ {
size_t addr_len = colon_pos - uri; size_t addr_len = colon_pos - uri;
buf = malloc(addr_len + 1); buf = malloc(addr_len + 1);
...@@ -69,8 +70,15 @@ char* MQTTProtocol_addressPort(const char* uri, int* port) ...@@ -69,8 +70,15 @@ char* MQTTProtocol_addressPort(const char* uri, int* port)
len = strlen(buf); len = strlen(buf);
if (buf[len - 1] == ']') if (buf[len - 1] == ']')
buf[len - 1] = '\0'; {
if (buf == (char*)uri)
{
buf = malloc(len); /* we are stripping off the final ], so length is 1 shorter */
MQTTStrncpy(buf, uri, len);
}
else
buf[len - 1] = '\0';
}
FUNC_EXIT; FUNC_EXIT;
return buf; return buf;
} }
......
...@@ -237,7 +237,7 @@ void onSubscribeFailure(void* context, MQTTAsync_failureData* response) ...@@ -237,7 +237,7 @@ void onSubscribeFailure(void* context, MQTTAsync_failureData* response)
void onConnectFailure(void* context, MQTTAsync_failureData* response) void onConnectFailure(void* context, MQTTAsync_failureData* response)
{ {
printf("Connect failed, rc %d\n", response->code); printf("Connect failed, rc %d\n", response ? response->code : -99);
finished = 1; finished = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment