File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -971,7 +971,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
971971 mqtt_connack_data_t connack_data = {0 };
972972 MQTTPacket_connectData connect_data = MQTTPacket_connectData_initializer ;
973973
974- if (NULL == c )
974+ if (NULL == c || NULL == c -> mqtt_network )
975975 RETURN_ERROR (MQTT_NULL_VALUE_ERROR );
976976
977977 if (CLIENT_STATE_CONNECTED == mqtt_get_client_state (c ))
@@ -983,12 +983,14 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
983983 rc = network_init (c -> mqtt_network , c -> mqtt_host , c -> mqtt_port , NULL );
984984#endif
985985
986+ if (rc != MQTT_SUCCESS_ERROR ) {
987+ RETURN_ERROR (rc );
988+ }
989+
986990 rc = network_connect (c -> mqtt_network );
987991 if (MQTT_SUCCESS_ERROR != rc ) {
988- if (NULL != c -> mqtt_network ) {
989- network_release (c -> mqtt_network );
990- RETURN_ERROR (rc );
991- }
992+ network_release (c -> mqtt_network );
993+ RETURN_ERROR (rc );
992994 }
993995
994996 MQTT_LOG_I ("mqtt-client:%d %s()... mqtt connect success..." , __LINE__ , __FUNCTION__ );
You can’t perform that action at this time.
0 commit comments