Fix some small memory leaks.

This commit is contained in:
Jan Vidar Krey 2010-04-21 18:34:55 +02:00
parent b6fb2b41bd
commit 076492f1b9
4 changed files with 15 additions and 22 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}