BugID:17023372:[WhiteScan] [579408]:fix Resource leak
@@ -3429,12 +3429,15 @@ void *IOT_MQTT_Construct(iotx_mqtt_param_t *pInitParams)
pInitParams = mqtt_params;
}
- STRING_PTR_SANITY_CHECK(pInitParams->host, NULL);
- STRING_PTR_SANITY_CHECK(pInitParams->client_id, NULL);
- STRING_PTR_SANITY_CHECK(pInitParams->username, NULL);
- STRING_PTR_SANITY_CHECK(pInitParams->password, NULL);
+ if (pInitParams->host == NULL || pInitParams->client_id == NULL ||
+ pInitParams->username == NULL || pInitParams->password == NULL) {
+ mqtt_err("init params is not complete");
+ if (mqtt_params != NULL) {
+ mqtt_free(mqtt_params);
+ }
+ return NULL;
+ }
- mqtt_debug("sizeof(iotx_mc_client_t) = %d!", sizeof(iotx_mc_client_t));
pclient = (iotx_mc_client_t *)mqtt_malloc(sizeof(iotx_mc_client_t));
if (NULL == pclient) {
mqtt_err("not enough memory.");
