diff --git a/src/core/ngx_crypt.c b/src/core/ngx_crypt.c
index 629d160..f3844a7 100644
--- a/src/core/ngx_crypt.c
+++ b/src/core/ngx_crypt.c
@@ -137,7 +137,8 @@ ngx_crypt_apr1(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
 
     /* output */
 
-    *encrypted = ngx_pnalloc(pool, sizeof("$apr1$") - 1 + saltlen + 16 + 1);
+    /*                             $apr1$                 saltlen   $   md5    \0 */
+    *encrypted = ngx_pnalloc(pool, sizeof("$apr1$") - 1 + saltlen + 1 + 4*5+2 + 1);
     if (*encrypted == NULL) {
         return NGX_ERROR;
     }
