LDAP: Possible memory leak in build_mods_from_contacts()
https://gitlab.gnome.org/GNOME/evolution-data-server/-/blob/master/src/addressbook/backends/ldap/e-book-backend-ldap.c#L1279 can have this flow:
{
LDAPMod *mod = g_new (LDAPMod, 1);
gchar *ldap_uid_value = strchr (ldap_uid, '=');
if (ldap_uid_value) {
mod->mod_op = LDAP_MOD_ADD;
mod->mod_type = g_strdup ("uid");
mod->mod_values = g_new (gchar *, 2);
mod->mod_values[0] = g_strdup (ldap_uid_value + 1);
mod->mod_values[1] = NULL;
g_ptr_array_add (result, mod);
}
}
When ldap_uid_value is NULL, the value pointed to by mod is leaked.
I found this with clang static analyzer --ctu and CodeChecker:
$ ninja -t clean
$ CodeChecker log --build "ninja" --output ./compile_commands.json
$ CodeChecker analyze ./compile_commands.json --output ./reports --ctu
$ CodeChecker parse --export html --output ./reports_html ./reports
The complete results, including false positives, are uploaded at https://mail.aegee.org/dpa/scan99/eds/.
Edited by Milan Crha