Permission: use std::string for temporary password allocation
As a side effect, this fixes a memory leak.
This commit is contained in:
parent
8ed9f7effa
commit
e13d0bf656
|
@ -75,7 +75,6 @@ static unsigned parsePermissions(const char *string)
|
||||||
|
|
||||||
void initPermissions(void)
|
void initPermissions(void)
|
||||||
{
|
{
|
||||||
char *password;
|
|
||||||
unsigned permission;
|
unsigned permission;
|
||||||
const struct config_param *param;
|
const struct config_param *param;
|
||||||
|
|
||||||
|
@ -97,12 +96,11 @@ void initPermissions(void)
|
||||||
PERMISSION_PASSWORD_CHAR,
|
PERMISSION_PASSWORD_CHAR,
|
||||||
param->value, param->line);
|
param->value, param->line);
|
||||||
|
|
||||||
password = g_strndup(param->value,
|
std::string password((const char *)param->value, separator);
|
||||||
separator - param->value);
|
|
||||||
|
|
||||||
permission = parsePermissions(separator + 1);
|
permission = parsePermissions(separator + 1);
|
||||||
|
|
||||||
permission_passwords.insert(std::make_pair(password,
|
permission_passwords.insert(std::make_pair(std::move(password),
|
||||||
permission));
|
permission));
|
||||||
} while ((param = config_get_next_param(CONF_PASSWORD, param)));
|
} while ((param = config_get_next_param(CONF_PASSWORD, param)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue