Skip to content

Commit 43ff841

Browse files
committed
修复subscribe的因为没对齐引起的死机问题
1 parent 22bbdb3 commit 43ff841

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

mqttclient/mqttclient.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,8 +1315,10 @@ int mqtt_subscribe(mqtt_client_t* c, const char* topic_filter, mqtt_qos_t qos, m
13151315

13161316
packet_id = mqtt_get_next_packet_id(c);
13171317

1318+
int qos_level = qos; /* This can avoid alignment bugs, because enum is not int on some compilers */
1319+
13181320
/* serialize subscribe packet and send it */
1319-
len = MQTTSerialize_subscribe(c->mqtt_write_buf, c->mqtt_write_buf_size, 0, packet_id, 1, &topic, (int*)&qos);
1321+
len = MQTTSerialize_subscribe(c->mqtt_write_buf, c->mqtt_write_buf_size, 0, packet_id, 1, &topic, (int *)&qos_level);
13201322
if (len <= 0)
13211323
goto exit;
13221324

0 commit comments

Comments
 (0)