diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-03-25 17:56:07 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-03-25 17:56:07 +0100 |
commit | 94cbed25853bcb4d43a4468eb9ee0cc3f42b0595 (patch) | |
tree | 6ba8ce758c7f47607e89ccc7215b21137886c24c /src | |
parent | 675e63948c399b7b895e7ea1a4d85420d912da3b (diff) | |
download | weechat-94cbed25853bcb4d43a4468eb9ee0cc3f42b0595.zip |
core: fix memory leak in function config_file_read_internal
This was caused by commit 66571a0b634ef28307f6d6ceef1ba29c091ca524.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config-file.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 0cbf88bd1..52f0011c7 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -3346,9 +3346,12 @@ config_file_read_internal (struct t_config_file *config_file, int reload) { line_number++; + option = NULL; + value = NULL; + ptr_line = fgets (line, sizeof (line) - 1, config_file->file); if (!ptr_line) - continue; + goto end_line; /* encode line to internal charset */ ptr_line2 = string_iconv_to_internal (NULL, ptr_line); @@ -3374,7 +3377,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload) /* ignore empty line or comment */ if (!ptr_line[0] || (ptr_line[0] == '#')) - continue; + goto end_line; /* beginning of section */ if ((ptr_line[0] == '[') && !strchr (ptr_line, '=')) @@ -3409,13 +3412,9 @@ config_file_read_internal (struct t_config_file *config_file, int reload) free (section); } } - continue; + goto end_line; } - /* option */ - option = NULL; - value = NULL; - /* skip escape char */ if (ptr_line[0] == '\\') ptr_line++; @@ -3496,7 +3495,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload) config_file->version); } } - continue; + goto end_line; } if (!ptr_section) @@ -3507,7 +3506,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload) gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], filename, line_number, line); - continue; + goto end_line; } config_file_update_data_read (config_file, @@ -3516,7 +3515,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload) /* option has been ignored by the update callback? */ if (!option || !option[0]) - continue; + goto end_line; if (ptr_section->callback_read) { @@ -3576,6 +3575,7 @@ config_file_read_internal (struct t_config_file *config_file, int reload) break; } + end_line: if (option) free (option); if (value) |