diff options
author | Max Kellermann <max@duempel.org> | 2013-10-15 22:40:17 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-10-15 22:48:09 +0200 |
commit | e13d0bf65653550c4cfe3f879441139f5242d8b1 (patch) | |
tree | f46300dc42158d4b1f0bf61a9f225ae91fc131ef /src/Permission.cxx | |
parent | 8ed9f7effac54897fc5fc461b1a2e6e0309aba51 (diff) | |
download | mpd-e13d0bf65653550c4cfe3f879441139f5242d8b1.tar.gz mpd-e13d0bf65653550c4cfe3f879441139f5242d8b1.tar.xz mpd-e13d0bf65653550c4cfe3f879441139f5242d8b1.zip |
Permission: use std::string for temporary password allocation
As a side effect, this fixes a memory leak.
Diffstat (limited to 'src/Permission.cxx')
-rw-r--r-- | src/Permission.cxx | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/Permission.cxx b/src/Permission.cxx index 258ace60a..f53465b83 100644 --- a/src/Permission.cxx +++ b/src/Permission.cxx @@ -75,7 +75,6 @@ static unsigned parsePermissions(const char *string) void initPermissions(void) { - char *password; unsigned permission; const struct config_param *param; @@ -97,12 +96,11 @@ void initPermissions(void) PERMISSION_PASSWORD_CHAR, param->value, param->line); - password = g_strndup(param->value, - separator - param->value); + std::string password((const char *)param->value, separator); permission = parsePermissions(separator + 1); - permission_passwords.insert(std::make_pair(password, + permission_passwords.insert(std::make_pair(std::move(password), permission)); } while ((param = config_get_next_param(CONF_PASSWORD, param))); } |