From 951a263dcd824efac116bf0369495c4bf736c191 Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Wed, 28 Sep 2022 14:19:29 +0100 Subject: [PATCH] Fix up suback count check --- src/MQTTClient.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/MQTTClient.c b/src/MQTTClient.c index c3effdc..8f156b0 100644 --- a/src/MQTTClient.c +++ b/src/MQTTClient.c @@ -2080,17 +2080,19 @@ MQTTResponse MQTTClient_subscribeMany5(MQTTClient handle, int count, char* const } else { - if (count < sub->qoss->count) - { + ListElement *current = NULL; + + /* if the returned count is greater than requested, it's an error*/ + if (sub->qoss->count > count) rc = MQTTCLIENT_FAILURE; - goto exit; - } - ListElement* current = NULL; - i = 0; - while (ListNextElement(sub->qoss, ¤t)) + else { - int* reqqos = (int*)(current->content); - qos[i++] = *reqqos; + i = 0; + while (ListNextElement(sub->qoss, ¤t)) + { + int *reqqos = (int*) (current->content); + qos[i++] = *reqqos; + } } resp.reasonCode = rc; } -- GitLab