Commit cecadffb authored by David Woodhouse's avatar David Woodhouse

Make dup_config_arg() always duplicate the argument

.... even when conversion fails. Otherwise we end up trying to free a
member of argv[], which never works well.
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 71428d03
......@@ -913,9 +913,21 @@ static char *xstrdup(const char *arg)
#define keep_config_arg() \
(config_file ? xstrdup(config_arg) : convert_arg_to_utf8(argv, config_arg))
#define dup_config_arg() \
((config_file || is_arg_utf8(config_arg)) ? xstrdup(config_arg) : \
convert_arg_to_utf8(argv, config_arg))
#define dup_config_arg() __dup_config_arg(argv, config_arg)
static inline char *__dup_config_arg(char **argv, char *config_arg)
{
char *res;
if (config_file || is_arg_utf8(config_arg))
return xstrdup(config_arg);
res = convert_arg_to_utf8(argv, config_arg);
/* Force a copy, even if conversion failed */
if (res == config_arg)
res = xstrdup(res);
return res;
}
static int next_option(int argc, char **argv, char **config_arg)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment