BugID:17646749:[mqtt] add payload null check for publish
@@ -1501,15 +1501,18 @@ static int iotx_mc_handle_recv_SUBACK(iotx_mc_client_t *c)
/* call callback function to notify that SUBSCRIBE is successful */
iotx_mqtt_event_msg_t msg;
msg.msg = (void *)(uintptr_t)mypacketid;
- if (fail_flag == 1) {
+ if (fail_flag == 1)
+ {
msg.event_type = IOTX_MQTT_EVENT_SUBCRIBE_NACK;
- } else {
+ } else
+ {
msg.event_type = IOTX_MQTT_EVENT_SUBCRIBE_SUCCESS;
}
_iotx_mqtt_event_handle_sub(c->handle_event.pcontext, c, &msg);
- if (NULL != c->handle_event.h_fp) {
+ if (NULL != c->handle_event.h_fp)
+ {
_handle_event(&c->handle_event, c, &msg);
}
@@ -1636,6 +1639,7 @@ static int iotx_mc_handle_recv_UNSUBACK(iotx_mc_client_t *c)
HAL_MutexUnlock(c->lock_list_sub);
if (NULL == messageHandler || NULL == messageHandler->topic_filter) {
+ mqtt_debug("------------------------------------------------");
return MQTT_SUB_INFO_NOT_FOUND_ERROR;
}
@@ -2031,9 +2035,10 @@ int iotx_mc_publish(iotx_mc_client_t *c, const char *topicName, iotx_mqtt_topic_
uint16_t msg_id = 0;
int rc = FAIL_RETURN;
- if (NULL == c || NULL == topicName || NULL == topic_msg) {
- return NULL_VALUE_ERROR;
- }
+ ARGUMENT_SANITY_CHECK(c, NULL_VALUE_ERROR);
+ ARGUMENT_SANITY_CHECK(topicName, NULL_VALUE_ERROR);
+ ARGUMENT_SANITY_CHECK(topic_msg, NULL_VALUE_ERROR);
+ ARGUMENT_SANITY_CHECK(topic_msg->payload, NULL_VALUE_ERROR);
if (0 != iotx_mc_check_topic(topicName, TOPIC_NAME_TYPE)) {
mqtt_err("topic format is error,topicFilter = %s", topicName);
@@ -2843,6 +2848,10 @@ static void iotx_sub_wait_ack_list_destroy(iotx_mc_client_t *pClient)
list_for_each_entry_safe(node, next_node, &pClient->list_sub_wait_ack, linked_list, iotx_mc_subsribe_info_t) {
list_del(&node->linked_list);
+ if (node->handler != NULL) {
+ mqtt_free(node->handler->topic_filter);
+ mqtt_free(node->handler);
+ }
mqtt_free(node);
}
}
