We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在阅读源码时,发现mqtt_subscribe()函数里的msg_handler->topic_filter指针指向的是形参的地址,而没有保存完整的字符串内容。 如果topic_filter传入的是一个局部变量指向的缓冲区,调用mqtt_subscribe是不是会有问题?
int mqtt_subscribe(mqtt_client_t* c, const char* topic_filter, mqtt_qos_t qos, message_handler_t handler) { //....... /* create a message and record it */ msg_handler = mqtt_msg_handler_create(topic_filter, qos, handler); if (NULL == msg_handler) { rc = MQTT_MEM_NOT_ENOUGH_ERROR; goto exit; } //....... } static message_handlers_t *mqtt_msg_handler_create(const char* topic_filter, mqtt_qos_t qos, message_handler_t handler) { message_handlers_t *msg_handler = NULL; msg_handler = (message_handlers_t *) platform_memory_alloc(sizeof(message_handlers_t)); if (NULL == msg_handler) return NULL; mqtt_list_init(&msg_handler->list); msg_handler->qos = qos; msg_handler->handler = handler; /* register callback handler */ msg_handler->topic_filter = topic_filter; //这里仅保存了传入的指针,而没有保存完整的字符串内容。 return msg_handler; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在阅读源码时,发现mqtt_subscribe()函数里的msg_handler->topic_filter指针指向的是形参的地址,而没有保存完整的字符串内容。
如果topic_filter传入的是一个局部变量指向的缓冲区,调用mqtt_subscribe是不是会有问题?
The text was updated successfully, but these errors were encountered: