about summary refs log tree commit diff
path: root/crypt/md5-crypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypt/md5-crypt.c')
-rw-r--r--crypt/md5-crypt.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/crypt/md5-crypt.c b/crypt/md5-crypt.c
index e99f8ca199..66eda28d0c 100644
--- a/crypt/md5-crypt.c
+++ b/crypt/md5-crypt.c
@@ -234,14 +234,15 @@ __md5_crypt_r (key, salt, buffer, buflen)
 }
 
 
+static char *buffer;
+
 char *
 __md5_crypt (const char *key, const char *salt)
 {
   /* We don't want to have an arbitrary limit in the size of the
      password.  We can compute the size of the result in advance and
      so we can prepare the buffer we pass to `md5_crypt_r'.  */
-  static char *buffer = NULL;
-  static int buflen = 0;
+  static int buflen;
   int needed = 3 + strlen (salt) + 1 + 26 + 1;
 
   if (buflen < needed)
@@ -253,3 +254,11 @@ __md5_crypt (const char *key, const char *salt)
 
   return __md5_crypt_r (key, salt, buffer, buflen);
 }
+
+
+static void
+__attribute__ ((__constructor__))
+free_mem (void)
+{
+  free (buffer);
+}