diff --git a/lighthub/candriver.cpp b/lighthub/candriver.cpp index e27163c..6411dcd 100644 --- a/lighthub/candriver.cpp +++ b/lighthub/candriver.cpp @@ -570,7 +570,7 @@ return 0; aJsonObject * canDriver::getConfbyID(uint8_t devId) { if (!canConfigObj) return NULL; -if (!canRemoteConfigObj) return NULL; +if (!canRemoteConfigObj || canRemoteConfigObj->type != aJson_Object) return NULL; aJsonObject * remoteConfObj=canRemoteConfigObj->child; while (remoteConfObj) { @@ -587,7 +587,7 @@ return NULL; aJsonObject * canDriver::findConfbyName(char* devName, int * devAddr) { -if (!canRemoteConfigObj && !devName) return NULL; +if (!canRemoteConfigObj || canRemoteConfigObj->type != aJson_Object || !devName ) return NULL; aJsonObject * remoteConfObj=canRemoteConfigObj->child; while (remoteConfObj) { @@ -616,7 +616,7 @@ extern PubSubClient mqttClient; bool canDriver::subscribeTopics(char * root, size_t buflen) { if (!root) return false; - if (!canRemoteConfigObj) return false; + if (!canRemoteConfigObj || canRemoteConfigObj->type != aJson_Object) return false; int rootLen = strlen(root); diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 1d082bc..7e27a3e 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -341,13 +341,13 @@ uint16_t getCanNum(aJsonObject* verb) case aJson_Array: { aJsonObject *canNumObj=aJson.getArrayItem(verb,1); - if (canNumObj->type == aJson_Int) return canNumObj->valueint; + if (canNumObj && canNumObj->type == aJson_Int) return canNumObj->valueint; return 0; } case aJson_Object: { aJsonObject *canNumObj=aJson.getObjectItem(verb, "can"); - if (canNumObj->type == aJson_Int) return canNumObj->valueint; + if (canNumObj && canNumObj->type == aJson_Int) return canNumObj->valueint; return 0; } } diff --git a/lighthub/main.cpp b/lighthub/main.cpp index c76fa00..8dabe23 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -2717,6 +2717,18 @@ infoSerial<