Add Invalid TopicId check.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2019-10-04 21:12:00 +09:00
parent 7aa44d94d1
commit 65583a6887

View File

@@ -416,10 +416,16 @@ Client* ClientList::createClient(SensorNetAddress* addr, MQTTSNString* clientId,
Client* ClientList::createPredefinedTopic( MQTTSNString* clientId, string topicName, uint16_t topicId, bool aggregate) Client* ClientList::createPredefinedTopic( MQTTSNString* clientId, string topicName, uint16_t topicId, bool aggregate)
{ {
if ( topicId == 0 )
{
WRITELOG("Invalid TopicId. Predefined Topic %s, TopicId is 0. \n", topicName.c_str());
return nullptr;
}
if ( strcmp(clientId->cstring, common_topic) == 0 ) if ( strcmp(clientId->cstring, common_topic) == 0 )
{ {
theGateway->getTopics()->add((const char*)topicName.c_str(), topicId); theGateway->getTopics()->add((const char*)topicName.c_str(), topicId);
return 0; return nullptr;
} }
else else
{ {
@@ -427,7 +433,7 @@ Client* ClientList::createPredefinedTopic( MQTTSNString* clientId, string topicN
if ( _authorize && client == nullptr ) if ( _authorize && client == nullptr )
{ {
return 0; return nullptr;
} }
/* anonimous clients */ /* anonimous clients */