ESP8266 crash after MQTTtoPilight


#1

It is possible to produce a NULL Pointer Exception (some kind of) forcing the ESP to reboot.
Removing the “id” property in the Json string to MQTTtoPilight tries to use a NULL value as source in a strcpy().

Current ZgatewayPilight.ino

      DynamicJsonBuffer jb;
      JsonObject& rjson = jb.parseObject(MQTTmessage);
      if (rjson.success()) {
        strcpy(deviceID, rjson["id"]);  /* crash */
      }

should read…

      DynamicJsonBuffer jb;
      JsonObject& rjson = jb.parseObject(MQTTmessage);
      if (rjson.success() && rjson.containsKey("id")) {
        strcpy(deviceID, rjson["id"]);
      }

#2

Sorry but I can’t find this part of code, could you point me where did you find it?


#3

Sorry, this part was removed by commit d8dba15a8151f8270b852b89d07b90626aff28da


#4

Does it still crash for you ?


#5

Version 0.8 with the added “containsKey()” check does not crash any more.
I have not tested version 0.9 beta.


#6

I would be very interested by your feedback of ZgatewayPilight with v0.9beta if you could take a look to it.