Skip to content

Commit

Permalink
Fix oss-fuzz #68456
Browse files Browse the repository at this point in the history
Fix cleanup on exit due to error.
  • Loading branch information
ralight committed May 1, 2024
1 parent 2754b66 commit 1bb2299
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static int config__check_bridges(struct mosquitto__config *config);
static int config__add_listener(struct mosquitto__config *config)
{
struct mosquitto__listener *listener;
struct mosquitto__listener **new_listeners;
int def_listener = -1;

if(config->default_listener){
Expand All @@ -152,11 +153,12 @@ static int config__add_listener(struct mosquitto__config *config)
}
}
}
config->listeners = mosquitto_realloc(config->listeners, sizeof(struct mosquitto__listener)*(size_t)(config->listener_count+1));
if(!config->listeners){
new_listeners = mosquitto_realloc(config->listeners, sizeof(struct mosquitto__listener)*(size_t)(config->listener_count+1));
if(!new_listeners){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Out of memory.");
return MOSQ_ERR_NOMEM;
}
config->listeners = new_listeners;
listener = &config->listeners[config->listener_count];
memset(listener, 0, sizeof(struct mosquitto__listener));
listener->security_options = mosquitto_calloc(1, sizeof(struct mosquitto__security_options));
Expand Down

1 comment on commit 1bb2299

@h31p
Copy link

@h31p h31p commented on 1bb2299 May 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you ever check if it compiles?

either line 145 has an extra asterisk, or line 161 misses one.

Please sign in to comment.