diff --git a/ChangeLog.txt b/ChangeLog.txt index 86892189..43d6ec4b 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,10 @@ +1.3.5 - 20141005 +================ + +Broker: +- Fix possible memory leak when using a topic that has a leading slash. Fixes + bug #1360985. + 1.3.4 - 20140806 ================ diff --git a/src/subs.c b/src/subs.c index 31c9d7e0..a171ec82 100644 --- a/src/subs.c +++ b/src/subs.c @@ -155,8 +155,13 @@ static int _sub_topic_tokenise(const char *subtopic, struct _sub_token **topics) new_topic->topic = _mosquitto_strdup(""); if(!new_topic->topic) goto cleanup; - *topics = new_topic; - tail = new_topic; + if(tail){ + tail->next = new_topic; + tail = tail->next; + }else{ + *topics = new_topic; + tail = new_topic; + } } len = strlen(subtopic); @@ -168,8 +173,13 @@ static int _sub_topic_tokenise(const char *subtopic, struct _sub_token **topics) new_topic->topic = _mosquitto_strdup(""); if(!new_topic->topic) goto cleanup; - *topics = new_topic; - tail = new_topic; + if(tail){ + tail->next = new_topic; + tail = tail->next; + }else{ + *topics = new_topic; + tail = new_topic; + } start = 1; }else{