File PolicyKit-0.9-fix-memory-leaks.diff of Package PolicyKit

commit 70651e5ff2cf6408525dd67b2b60c2067af4387c
Author: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
Date:   Wed Sep 23 16:54:12 2009 +0200

    Prevent several memory leaks

    polkit_context_unref fails to delete the dynamically allocated objects
    associated with the context when said object is unreferenced.

    There's an additional memory leak when the default authentification
    database contains overriding entries -- temporaries created during
    parsing are not correctly freed.

    Signed-off-by: Wolfgang Mauerer <wolfgang.mauerer@siemens.com>
    Reported-by: Uwe Krebs <uwe.krebs@siemens-enterprise.com>

Index: PolicyKit-0.9/src/polkit/polkit-context.c
===================================================================
--- PolicyKit-0.9.orig/src/polkit/polkit-context.c
+++ PolicyKit-0.9/src/polkit/polkit-context.c
@@ -464,6 +464,10 @@ polkit_context_unref (PolKitContext *pk_
         if (pk_context->refcount > 0) 
                 return;
 
+        polkit_authorization_db_unref (pk_context->authdb);
+        polkit_config_unref (pk_context->config);
+        polkit_policy_cache_unref (pk_context->priv_cache);
+        kit_free (pk_context->policy_dir);
         kit_free (pk_context);
 }
 
Index: PolicyKit-0.9/src/polkit/polkit-policy-file-entry.c
===================================================================
--- PolicyKit-0.9.orig/src/polkit/polkit-policy-file-entry.c
+++ PolicyKit-0.9/src/polkit/polkit-policy-file-entry.c
@@ -160,22 +160,28 @@ _polkit_policy_file_entry_new   (const c
                 PolKitResult active;
 
                 tokens = kit_strsplit (contents, ':', &num_tokens);
-                if (num_tokens != 3)
+                if (num_tokens != 3) {
+                        kit_strfreev(tokens);
                         goto error;
+                }
 
                 if (!polkit_result_from_string_representation (tokens[0], &any)) {
+                        kit_strfreev(tokens);
                         goto error;
                 }
                 if (!polkit_result_from_string_representation (tokens[1], &inactive)) {
+                        kit_strfreev(tokens);
                         goto error;
                 }
                 if (!polkit_result_from_string_representation (tokens[2], &active)) {
+                        kit_strfreev(tokens);
                         goto error;
                 }
 
                 polkit_policy_default_set_allow_any      (pfe->defaults, any);
                 polkit_policy_default_set_allow_inactive (pfe->defaults, inactive);
                 polkit_policy_default_set_allow_active   (pfe->defaults, active);
+                kit_strfreev(tokens);
         }
 #endif
 
openSUSE Build Service is sponsored by