Fix memleak in pgsql_reread_realms (#1278)

Fixes #1259

If `ur_string_map_put ` fails then the string that was just `strdup`-ed
will leak memory
Now the return value is checked and memory free-ed in case of failure
This commit is contained in:
Pavel Punsky 2023-10-02 07:20:14 -07:00 committed by GitHub
parent 88ced47138
commit 95c2967252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -777,7 +777,10 @@ static void pgsql_reread_realms(secrets_list_t *realms_list) {
if (rval) {
get_realm(rval);
ur_string_map_value_type value = strdup(rval);
ur_string_map_put(o_to_realm_new, (ur_string_map_key_type)oval, value);
int ret = ur_string_map_put(o_to_realm_new, (ur_string_map_key_type)oval, value);
if (ret == -1) {
free(value);
}
}
}
}