Skip to content

Commit

Permalink
Fix realloc with size==0
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Jun 18, 2024
1 parent 2f32fcd commit f7d44ba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,11 @@ void bridge__cleanup(struct mosquitto *context)
}

db.bridge_count--;
db.bridges = mosquitto_realloc(db.bridges, (unsigned) db.bridge_count * sizeof(db.bridges[0]));
if(db.bridge_count == 0){
mosquitto_FREE(db.bridges);
}else{
db.bridges = mosquitto_realloc(db.bridges, (unsigned) db.bridge_count * sizeof(db.bridges[0]));
}

mosquitto_FREE(context->bridge->name);
mosquitto_FREE(context->bridge->local_clientid);
Expand Down

0 comments on commit f7d44ba

Please sign in to comment.