diff --git a/src/MQTTClient.c b/src/MQTTClient.c index c3effdc41ea8914c7802d4852a2b4d18b5f38ea3..8f156b08bfada23cc349a0ae3e30983acc0a8169 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; }