Fix minor valgrind issues
- Fix valgrind invalid write of 1 byte. - Fix a few plugin related memory leaks.
This commit is contained in:
parent
c17b43e77f
commit
9f16298688
@ -50,16 +50,19 @@ struct uhub_plugin* plugin_open(const char* filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
plugin->filename = strdup(filename);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
void plugin_close(struct uhub_plugin* plugin)
|
||||
{
|
||||
LOG_TRACE("plugin_close: \"%s\"", plugin->filename);
|
||||
#ifdef HAVE_DLOPEN
|
||||
dlclose(plugin->handle);
|
||||
#else
|
||||
FreeLibrary((HMODULE) plugin->handle);
|
||||
#endif
|
||||
hub_free(plugin->filename);
|
||||
hub_free(plugin);
|
||||
}
|
||||
|
||||
@ -127,6 +130,7 @@ void plugin_unload(struct plugin_handle* plugin)
|
||||
{
|
||||
plugin->handle->unregister(plugin);
|
||||
plugin_close(plugin->handle);
|
||||
hub_free(plugin);
|
||||
}
|
||||
|
||||
static int plugin_parse_line(char* line, int line_count, void* ptr_data)
|
||||
@ -186,7 +190,12 @@ int plugin_initialize(struct hub_config* config, struct uhub_plugins* handle)
|
||||
|
||||
ret = file_read_lines(config->file_plugins, handle, &plugin_parse_line);
|
||||
if (ret == -1)
|
||||
{
|
||||
list_clear(handle->loaded, hub_free);
|
||||
list_destroy(handle->loaded);
|
||||
handle->loaded = 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ struct uhub_plugin
|
||||
{
|
||||
void* handle;
|
||||
plugin_unregister_f unregister;
|
||||
char* filename;
|
||||
};
|
||||
|
||||
struct uhub_plugins
|
||||
|
@ -100,6 +100,8 @@ static struct log_data* parse_config(const char* line, struct plugin_handle* plu
|
||||
token = cfg_token_get_next(tokens);
|
||||
}
|
||||
|
||||
cfg_tokens_free(tokens);
|
||||
|
||||
if (data->logmode == mode_file)
|
||||
{
|
||||
if ((data->logmode == mode_file && !data->logfile))
|
||||
|
@ -30,7 +30,7 @@ struct cfg_tokens
|
||||
struct cfg_tokens* cfg_tokenize(const char* line)
|
||||
{
|
||||
struct cfg_tokens* tokens = (struct cfg_tokens*) hub_malloc_zero(sizeof(struct cfg_tokens));
|
||||
char* buffer = (char*) hub_malloc_zero(strlen(line));
|
||||
char* buffer = (char*) hub_malloc_zero(strlen(line) + 1);
|
||||
char* out = buffer;
|
||||
const char* p = line;
|
||||
int backslash = 0;
|
||||
@ -68,6 +68,7 @@ struct cfg_tokens* cfg_tokenize(const char* line)
|
||||
else
|
||||
{
|
||||
RESET_TOKEN;
|
||||
hub_free(buffer);
|
||||
return tokens;
|
||||
}
|
||||
break;
|
||||
@ -115,6 +116,7 @@ struct cfg_tokens* cfg_tokenize(const char* line)
|
||||
}
|
||||
|
||||
RESET_TOKEN;
|
||||
hub_free(buffer);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user