paho.mqtt.embedded-c
paho.mqtt.embedded-c copied to clipboard
fix publish return err
Fixed segmentation error during data processing due to incorrect browser return value
Well, that is a too broad, misleading, and perhaps incorrect description. What I think I see (perhaps I'm not seeing what you see) is that in the event that not enough characters are received, rc in line 53 gets the number of chars decoded and so this trashes what otherwise would have been a correct return code (initialized in line 42). That, when returned, causes another function to fail and then somehow something breaks in your code and you see a segmentation error. (Many of us don't run this on an OS and we can't see segmentation errors, btw)
To me, a more appropriate way to fix this is to eliminate rc in line 53:
curdata += (rc = MQTTPacket_decodeBuf(curdata, &mylen)); /* read remaining length */
to
curdata += MQTTPacket_decodeBuf(curdata, &mylen); /* read remaining length */
or use a different holder for return value (instead of rc) in case we need it later or want to be neat.
Am I missing something ?