Commit 228a6ec9 authored by David Zeuthen's avatar David Zeuthen
Browse files

don't leak the copied authorizations list on OOM

Now the test suite passes again.
parent fdea41e3
......@@ -93,14 +93,16 @@ KitList *
kit_list_copy (KitList *list)
{
KitList *l;
KitList *l2;
KitList *j;
l = NULL;
for (j = list; j != NULL; j = j->next) {
/* TODO: prepend, then reverse */
l = kit_list_append (l, j->data);
if (l == NULL)
l2 = kit_list_append (l, j->data);
if (l2 == NULL)
goto oom;
l = l2;
}
return l;
......
......@@ -342,6 +342,8 @@ _authdb_get_auths_for_uid (PolKitAuthorizationDB *authdb,
goto out;
}
//kit_warning ("standard_output='%s'", standard_output);
if (standard_output != NULL) {
uid_t uid2;
len = strlen (standard_output);
......@@ -472,8 +474,12 @@ _internal_foreach (PolKitAuthorizationDB *authdb,
* may disappear from under us due to revoke_if_one_shot...
*/
auths_copy = kit_list_copy (auths);
if (auths_copy == NULL)
if (auths_copy == NULL) {
polkit_error_set_error (error,
POLKIT_ERROR_OUT_OF_MEMORY,
"No memory");
goto out;
}
for (l = auths_copy; l != NULL; l = l->next)
polkit_authorization_ref ((PolKitAuthorization *) l->data);
......@@ -1280,7 +1286,7 @@ _run_test (void)
//kit_warning ("%p: %d: %s: %s",
// error,
// polkit_error_get_error_code (error),
// polkit_error_get_error_name (error),
// polkit_error_get_error_name (error),
// polkit_error_get_error_message (error));
kit_assert (polkit_error_is_set (error) &&
polkit_error_get_error_code (error) == POLKIT_ERROR_OUT_OF_MEMORY);
......
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