diff --git a/src/adc/message.c b/src/adc/message.c index 49ccb0c..c54572a 100644 --- a/src/adc/message.c +++ b/src/adc/message.c @@ -88,6 +88,9 @@ static int adc_msg_grow(struct adc_message* msg, size_t size) char* buf; size_t newsize = 0; + if (!msg) + return 0; + if (msg->capacity > size) return 1; @@ -242,7 +245,10 @@ struct adc_message* adc_msg_copy(const struct adc_message* cmd) } if (!copy->cache) + { + adc_msg_free(copy); return NULL; + } memcpy(copy->cache, cmd->cache, cmd->length); copy->cache[copy->length] = 0; diff --git a/src/core/auth.c b/src/core/auth.c index 0583aef..6afb533 100644 --- a/src/core/auth.c +++ b/src/core/auth.c @@ -358,20 +358,10 @@ int acl_is_user_denied(struct acl_handle* handle, const char* data) int acl_user_ban_nick(struct acl_handle* handle, const char* nick) { - char* data = 0; - struct hub_user_access_info* info = hub_malloc_zero(sizeof(struct hub_user_access_info)); - - if (!info) - { - LOG_ERROR("ACL error: Out of memory!"); - return -1; - } - - data = hub_strdup(nick); + char* data = hub_strdup(nick); if (!data) { LOG_ERROR("ACL error: Out of memory!"); - hub_free(info); return -1; } @@ -381,19 +371,10 @@ int acl_user_ban_nick(struct acl_handle* handle, const char* nick) int acl_user_ban_cid(struct acl_handle* handle, const char* cid) { - char* data; - struct hub_user_access_info* info = hub_malloc_zero(sizeof(struct hub_user_access_info)); - if (!info) - { - LOG_ERROR("ACL error: Out of memory!"); - return -1; - } - - data = hub_strdup(cid); + char* data = hub_strdup(cid); if (!data) { LOG_ERROR("ACL error: Out of memory!"); - hub_free(info); return -1; } diff --git a/src/core/hub.c b/src/core/hub.c index b545c85..c042930 100644 --- a/src/core/hub.c +++ b/src/core/hub.c @@ -950,7 +950,12 @@ void hub_send_status(struct hub_info* hub, struct hub_user* user, enum status_me char* escaped_text = 0; int reconnect_time = 0; - if (!cmd) return; + if (!cmd || !qui) + { + adc_msg_free(cmd); + adc_msg_free(qui); + return; + } #define STATUS(CODE, MSG, FLAG, RCONTIME) case status_ ## MSG : set_status_code(level, CODE, code); text = cfg->MSG; flag = FLAG; reconnect_time = RCONTIME; break switch (msg) diff --git a/src/network/epoll.c b/src/network/epoll.c index 981acad..7385a74 100644 --- a/src/network/epoll.c +++ b/src/network/epoll.c @@ -160,6 +160,7 @@ struct net_backend* net_backend_init_epoll(struct net_backend_handler* handler, if (backend->epfd == -1) { LOG_WARN("Unable to create epoll socket."); + hub_free(backend); return 0; }