Skip to content

Commit 908d5d3

Browse files
committed
Fix BrokerHandle_Connect null check
1 parent 88d37ed commit 908d5d3

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)