utils: Free krb5 context for net_lookup_kdc
authorSwen Schillig <swen@linux.ibm.com>
Wed, 21 Nov 2018 12:17:38 +0000 (13:17 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 22 Nov 2018 07:22:19 +0000 (08:22 +0100)
In case of an error while processing and at the end of processing
the krb5 conext must be free'd.

Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/utils/net_lookup.c

index 05a3dbc6e2bb48971d49ece519262037483e9586..f94af266daa2a33df1d74dd62c944d40dfc97876 100644 (file)
@@ -304,6 +304,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
                if (rc) {
                        DEBUG(1,("krb5_gethost_realm failed (%s)\n",
                                 error_message(rc)));
+                       krb5_free_context(ctx);
                        return -1;
                }
                realm = (const char *) *realms;
@@ -312,6 +313,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
        status = get_kdc_list(realm, NULL, &kdcs, &num_kdcs);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1,("get_kdc_list failed (%s)\n", nt_errstr(status)));
+               krb5_free_context(ctx);
                return -1;
        }
 
@@ -323,6 +325,7 @@ static int net_lookup_kdc(struct net_context *c, int argc, const char **argv)
                d_printf("%s:%u\n", addr, kdcs[i].port);
        }
 
+       krb5_free_context(ctx);
        return 0;
 #endif
        DEBUG(1, ("No kerberos support\n"));