* enc_helper.c (krb5_encrypt_helper): NULL out the pointer to the
authorTom Yu <tlyu@mit.edu>
Tue, 29 Jun 1999 01:53:43 +0000 (01:53 +0000)
committerTom Yu <tlyu@mit.edu>
Tue, 29 Jun 1999 01:53:43 +0000 (01:53 +0000)
ciphertext if there is an error; this prevents stuff farther up
from freeing freed memory.

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

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/enc_helper.c

index 77a101ed07fb48fd1f6302d6df015ca0bf39ef52..1068b556bb6294f2e211bcadb4137be1f7212e42 100644 (file)
@@ -1,3 +1,9 @@
+1999-06-28  Tom Yu  <tlyu@mit.edu>
+
+       * enc_helper.c (krb5_encrypt_helper): NULL out the pointer to the
+       ciphertext if there is an error; this prevents stuff farther up
+       from freeing freed memory.
+
 1999-06-18  Ken Raeburn  <raeburn@mit.edu>
 
        * init_ctx.c (krb5_free_context): Set field pointers to NULL after
index ff4214937015b496f7364cc22ffc28aec3d3557c..0e988a08c3a5bc53f0b2011a3f2d53a8c22cbfa6 100644 (file)
@@ -44,9 +44,11 @@ krb5_encrypt_helper(context, key, usage, plain, cipher)
     cipher->ciphertext.length = enclen;
     if ((cipher->ciphertext.data = (char *) malloc(enclen)) == NULL)
        return(ret);
-
-    if (ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher))
+    ret = krb5_c_encrypt(context, key, usage, 0, plain, cipher);
+    if (ret) {
        free(cipher->ciphertext.data);
+       cipher->ciphertext.data = NULL;
+    }
 
     return(ret);
 }