* kdb_cpw.c (cleanup_key_data): fix memory leak [krb5-kdc/163]
authorBarry Jaspan <bjaspan@mit.edu>
Mon, 11 Nov 1996 22:06:43 +0000 (22:06 +0000)
committerBarry Jaspan <bjaspan@mit.edu>
Mon, 11 Nov 1996 22:06:43 +0000 (22:06 +0000)
(add_key_pwd): fix memory leak [krb5-kdc/164]

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

src/lib/kdb/ChangeLog
src/lib/kdb/kdb_cpw.c

index d4131f0f4584e975f7af9b8b6982bc64390568e6..cdd78eae8fe38cde6efbcd30f1e54dfbd54a2779 100644 (file)
@@ -1,3 +1,8 @@
+Mon Nov 11 17:03:16 1996  Barry Jaspan  <bjaspan@mit.edu>
+
+       * kdb_cpw.c (cleanup_key_data): fix memory leak [krb5-kdc/163]
+       (add_key_pwd): fix memory leak [krb5-kdc/164]
+
 Sat Nov  9 15:57:50 1996  Ezra Peisach  <epeisach@mit.edu>
 
        * t_krb5.conf: Dummy krb5.conf file from the krb5 library. 
index 54316dde097ad3680b39380c375a1944542a9062..c378ac6f90baf956538acb1d8a45649580c17897 100644 (file)
@@ -58,6 +58,7 @@ cleanup_key_data(context, count, data)
            }
        }
     }
+    free(data);
 }
 
 /*
@@ -408,15 +409,22 @@ add_key_pwd(context, master_eblock, ks_tuple, ks_tuple_count, passwd,
        pwd.data = passwd;
        pwd.length = strlen(passwd);
        if (retval = krb5_string_to_key(context, &key_eblock, &key, &pwd, 
-                                       &key_salt.data))
-           return(retval);
+                                       &key_salt.data)) {
+            if (key_salt.data.data)
+                 free(key_salt.data.data);
+            return(retval);
+       }
 
        if (retval = krb5_dbekd_encrypt_key_data(context, master_eblock, &key,
                     (const krb5_keysalt *)&key_salt,
                     kvno, &db_entry->key_data[db_entry->n_key_data-1])) {
+           if (key_salt.data.data)
+                free(key_salt.data.data);
            krb5_xfree(key.contents);
            return(retval);
        }
+       if (key_salt.data.data)
+            free(key_salt.data.data);
        krb5_xfree(key.contents);
     }
     return(retval);