catch error and, while here, destroy credential caches on error
authorLove Hörnquist Åstrand <lha@kth.se>
Fri, 27 Feb 2009 03:32:31 +0000 (03:32 +0000)
committerLove Hörnquist Åstrand <lha@kth.se>
Fri, 27 Feb 2009 03:32:31 +0000 (03:32 +0000)
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24866 ec53bebd-3082-4978-b11e-865c3cabbd6b

appl/su/su.c

index e2f4cb3b42e29efef02e6712d1afcf9ebe055da6..d568ef7803189cd5c98ce751091e5783cf6f8e7f 100644 (file)
@@ -237,11 +237,19 @@ krb5_start_session(void)
     }
 
     ret = krb5_cc_copy_cache(context, ccache, ccache2);
+    if (ret) {
+       krb5_cc_destroy(context, ccache);
+       krb5_cc_destroy(context, ccache2);
+       return 1;
+    }
 
     ret = asprintf(&cc_name, "%s:%s", krb5_cc_get_type(context, ccache2),
                   krb5_cc_get_name(context, ccache2));
-    if (ret == -1)
+    if (ret == -1) {
+       krb5_cc_destroy(context, ccache);
+       krb5_cc_destroy(context, ccache2);
        errx(1, "malloc - out of memory");
+    }
     esetenv("KRB5CCNAME", cc_name, 1);
 
     /* convert creds? */