Просмотр исходного кода

修正参数传递与引用方式不匹配造成的非法访问

aozima 6 лет назад
Родитель
Сommit
70c0d4e966
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      samples/mqtt/mqtt-example.c

+ 2 - 1
samples/mqtt/mqtt-example.c

@@ -115,12 +115,13 @@ static char* rt_strlwr(char *str)
 static void event_handle(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg)
 static void event_handle(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg)
 {
 {
     iotx_mqtt_topic_info_pt topic_info = (iotx_mqtt_topic_info_pt)msg->msg;
     iotx_mqtt_topic_info_pt topic_info = (iotx_mqtt_topic_info_pt)msg->msg;
+    uintptr_t packet_id = (uintptr_t)(msg->msg);
+
     if (topic_info == NULL)
     if (topic_info == NULL)
     {
     {
         rt_kprintf("Topic info is null! Exit.");
         rt_kprintf("Topic info is null! Exit.");
         return;
         return;
     }
     }
-    uintptr_t packet_id = (uintptr_t)topic_info->packet_id;
 
 
     switch (msg->event_type) {
     switch (msg->event_type) {
         case IOTX_MQTT_EVENT_UNDEF:
         case IOTX_MQTT_EVENT_UNDEF: