Don't deallocate key/salt tuples if supplied by caller to string_to_key
authorPaul Park <pjpark@mit.edu>
Tue, 8 Aug 1995 22:01:34 +0000 (22:01 +0000)
committerPaul Park <pjpark@mit.edu>
Tue, 8 Aug 1995 22:01:34 +0000 (22:01 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@6464 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/v5server/srv_key.c

index 37cdbf5731e2a4ba829a6d3e6ac66b5017d86507..c09a190904cfa7b9b5d015a093a119a857de70d0 100644 (file)
@@ -766,6 +766,7 @@ key_string_to_keys(kcontext, dbentp, string, nksalt, ksaltp, nkeysp, keysp)
     krb5_int32         nkeysalts;
     krb5_key_data      *keys;
     struct keysalt_iterate_args ksargs;
+    krb5_boolean       did_alloc;
 
     DPRINT(DEBUG_CALLS, key_debug_level, ("* key_string_to_keys()\n"));
 
@@ -775,8 +776,11 @@ key_string_to_keys(kcontext, dbentp, string, nksalt, ksaltp, nkeysp, keysp)
      */
     keysalts = ksaltp;
     nkeysalts = nksalt;
-    if (!keysalts || !nkeysalts)
+    did_alloc = 0;
+    if (!keysalts || !nkeysalts) {
        kret = key_dbent_to_keysalts(dbentp, &nkeysalts, &keysalts);
+       did_alloc = 1;
+    }
     if (keysalts && nkeysalts) {
        if (keys = (krb5_key_data *)
            malloc((size_t) (nkeysalts * sizeof(krb5_key_data)))) {
@@ -794,7 +798,8 @@ key_string_to_keys(kcontext, dbentp, string, nksalt, ksaltp, nkeysp, keysp)
        }
        else
            kret = ENOMEM;
-       krb5_xfree(keysalts);
+       if (did_alloc) 
+           krb5_xfree(keysalts);
     }
  done:
     if (!kret) {