Fix one more case of an explicit null check before calling a free
authorKen Raeburn <raeburn@mit.edu>
Mon, 9 Feb 2009 20:39:54 +0000 (20:39 +0000)
committerKen Raeburn <raeburn@mit.edu>
Mon, 9 Feb 2009 20:39:54 +0000 (20:39 +0000)
function that does the null check.

Also, use krb5_free_keyblock_contents instead of open-coding all the
work (and not trying hard enough to clear the memory).

ticket: 6377

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21926 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/kfree.c

index 2ddc0fa0fa77515a1e7a9803ce1567bcb4b5f73b..c7c1c602c379b74d64a412b38cb98184f25c4772 100644 (file)
@@ -60,8 +60,7 @@ krb5_free_address(krb5_context context, krb5_address *val)
 {
     if (val == NULL)
        return;
-    if (val->contents)
-       free(val->contents);
+    free(val->contents);
     free(val);
 }
 
@@ -188,11 +187,7 @@ krb5_free_cred_contents(krb5_context context, krb5_creds *val)
     val->client = 0;
     krb5_free_principal(context, val->server);
     val->server = 0;
-    if (val->keyblock.contents) {
-       memset(val->keyblock.contents, 0, val->keyblock.length);
-       free(val->keyblock.contents);
-       val->keyblock.contents = 0;
-    }
+    krb5_free_keyblock_contents(context, &val->keyblock);
     free(val->ticket.data);
     val->ticket.data = 0;
     free(val->second_ticket.data);