Sun, 10 Nov 2019 04:17:52 -0500
Fix undefined behaviour of default argument promotion to va_start.
| libpurple/protocols/facebook/mqtt.c | file | annotate | diff | comparison | revisions | |
| libpurple/protocols/facebook/mqtt.h | file | annotate | diff | comparison | revisions |
--- a/libpurple/protocols/facebook/mqtt.c Wed Nov 06 04:54:32 2019 +0000 +++ b/libpurple/protocols/facebook/mqtt.c Sun Nov 10 04:17:52 2019 -0500 @@ -791,7 +791,7 @@ } void -fb_mqtt_subscribe(FbMqtt *mqtt, const gchar *topic1, guint16 qos1, ...) +fb_mqtt_subscribe(FbMqtt *mqtt, ...) { const gchar *topic; FbMqttMessage *msg; @@ -808,15 +808,13 @@ FB_MQTT_MESSAGE_FLAG_QOS1); fb_mqtt_message_write_mid(msg, &priv->mid); /* Message identifier */ - fb_mqtt_message_write_str(msg, topic1); /* First topics */ - fb_mqtt_message_write_byte(msg, qos1); /* First QoS value */ - va_start(ap, qos1); + va_start(ap, mqtt); while ((topic = va_arg(ap, const gchar*)) != NULL) { qos = va_arg(ap, guint); - fb_mqtt_message_write_str(msg, topic); /* Remaining topics */ - fb_mqtt_message_write_byte(msg, qos); /* Remaining QoS values */ + fb_mqtt_message_write_str(msg, topic); + fb_mqtt_message_write_byte(msg, qos); } va_end(ap);
--- a/libpurple/protocols/facebook/mqtt.h Wed Nov 06 04:54:32 2019 +0000 +++ b/libpurple/protocols/facebook/mqtt.h Sun Nov 10 04:17:52 2019 -0500 @@ -339,15 +339,11 @@ /** * fb_mqtt_subscribe: * @mqtt: The #FbMqtt. - * @topic1: The first topic. - * @qos1: The first QoS. * @...: The %NULL-terminated list of topic/QoS pairs. * * Sends a message of type #FB_MQTT_MESSAGE_TYPE_SUBSCRIBE. */ -void -fb_mqtt_subscribe(FbMqtt *mqtt, const gchar *topic1, guint16 qos1, ...) - G_GNUC_NULL_TERMINATED; +void fb_mqtt_subscribe(FbMqtt *mqtt, ...) G_GNUC_NULL_TERMINATED; /** * fb_mqtt_unsubscribe: