Skip to content

Commit eb14efd

Browse files
authored
Merge pull request #477 from embhorn/bh_connect_fix
Fix BrokerHandle_Connect null check
2 parents 88d37ed + 908d5d3 commit eb14efd

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/mqtt_broker.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,11 +2872,13 @@ static int BrokerHandle_Connect(BrokerClient* bc, int rx_len,
28722872
BROKER_STORE_STR(bc->client_id, auto_id, (word16)id_len,
28732873
BROKER_MAX_CLIENT_ID_LEN);
28742874
}
2875-
prop = MqttProps_Add(&ack.props);
2876-
if (prop != NULL) {
2877-
prop->type = MQTT_PROP_ASSIGNED_CLIENT_ID;
2878-
prop->data_str.str = bc->client_id;
2879-
prop->data_str.len = (word16)XSTRLEN(bc->client_id);
2875+
if (BROKER_STR_VALID(bc->client_id)) {
2876+
prop = MqttProps_Add(&ack.props);
2877+
if (prop != NULL) {
2878+
prop->type = MQTT_PROP_ASSIGNED_CLIENT_ID;
2879+
prop->data_str.str = bc->client_id;
2880+
prop->data_str.len = (word16)XSTRLEN(bc->client_id);
2881+
}
28802882
}
28812883
}
28822884

0 commit comments

Comments
 (0)