From 2427c40a4cbd9de2de28c1a45054f274e108f73c Mon Sep 17 00:00:00 2001 From: "Sergio R. Caprile" Date: Fri, 29 Dec 2023 14:58:03 -0300 Subject: [PATCH] Avoid calling mg_send on no actual payload --- mongoose.c | 2 +- src/mqtt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mongoose.c b/mongoose.c index ca0effd5..b892772c 100644 --- a/mongoose.c +++ b/mongoose.c @@ -3990,7 +3990,7 @@ void mg_mqtt_pub(struct mg_connection *c, const struct mg_mqtt_opts *opts) { if (c->is_mqtt5) mg_send_mqtt_properties(c, opts->props, opts->num_props); - mg_send(c, opts->message.ptr, opts->message.len); + if (opts->message.len > 0) mg_send(c, opts->message.ptr, opts->message.len); } void mg_mqtt_sub(struct mg_connection *c, const struct mg_mqtt_opts *opts) { diff --git a/src/mqtt.c b/src/mqtt.c index a1cba49c..5301f586 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -338,7 +338,7 @@ void mg_mqtt_pub(struct mg_connection *c, const struct mg_mqtt_opts *opts) { if (c->is_mqtt5) mg_send_mqtt_properties(c, opts->props, opts->num_props); - mg_send(c, opts->message.ptr, opts->message.len); + if (opts->message.len > 0) mg_send(c, opts->message.ptr, opts->message.len); } void mg_mqtt_sub(struct mg_connection *c, const struct mg_mqtt_opts *opts) {