mqtt: fix Curl_read()  error handling while reading remaining length

Detected by Coverity. CID 1462320.

Closes #5274
diff --git a/lib/mqtt.c b/lib/mqtt.c
index 35c1b3e..4443336 100644
--- a/lib/mqtt.c
+++ b/lib/mqtt.c
@@ -569,6 +569,8 @@
         Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
       pkt[mq->npacket++] = byte;
     } while((byte & 0x80) && (mq->npacket < 4));
+    if(result)
+      break;
     mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL);
     mq->npacket = 0;
     if(mq->remaining_length) {