Skip to content

Commit b81f033

Browse files
authored
Update mqttclient.c
1 parent c835856 commit b81f033

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mqttclient/mqttclient.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ static int mqtt_is_topic_equals(const char *topic_filter, const char *topic)
230230

231231
static char mqtt_topic_is_matched(const char* topic_filter, MQTTString* topic_name)
232232
{
233-
const char* filter = topic_filter;
233+
const char* filter = topic_filter;
234234
const char* topic = topic_name->lenstring.data;
235-
int topic_len = topic_name != NULL && topic != NULL ? strnlen(topic, topic_name->lenstring.len) : 0;
236-
int filter_len = strlen(filter);
237-
int i = 0, j = 0;
235+
int topic_len = topic_name == NULL || topic_name->lenstring.data == NULL || topic_name->lenstring.len <= 0 ? 0 : strnlen(topic, topic_name->lenstring.len);
236+
int filter_len = strlen(filter);
237+
int i = 0, j = 0;
238238
while (i < filter_len && j < topic_len) {
239239
if (filter[i] == '#') {
240240
// '#' must be at the end and must be preceded by '/' or be the first character

0 commit comments

Comments
 (0)