Don't rearrange leaves here until we are sure we have all the memory allocated.

This commit is contained in:
Roger A. Light
2014-10-16 23:18:12 +01:00
parent eb01459571
commit 02be4965ea
+7 -7
View File
@@ -276,13 +276,6 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos,
leaf->next = NULL;
leaf->context = context;
leaf->qos = qos;
if(last_leaf){
last_leaf->next = leaf;
leaf->prev = last_leaf;
}else{
subhier->subs = leaf;
leaf->prev = NULL;
}
if(context->subs){
for(i=0; i<context->sub_count; i++){
if(!context->subs[i]){
@@ -309,6 +302,13 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos,
}
context->subs[0] = subhier;
}
if(last_leaf){
last_leaf->next = leaf;
leaf->prev = last_leaf;
}else{
subhier->subs = leaf;
leaf->prev = NULL;
}
#ifdef WITH_SYS_TREE
db->subscription_count++;
#endif