diff -ur openssl-1.0.1j/crypto/rand/md_rand.c openssl-1.0.1j.f/crypto/rand/md_rand.c --- openssl-1.0.1j/crypto/rand/md_rand.c 2014-10-15 14:53:39.000000000 +0200 +++ openssl-1.0.1j.f/crypto/rand/md_rand.c 2014-11-13 10:37:40.473283647 +0100 @@ -267,7 +267,11 @@ j=(num-i); j=(j > MD_DIGEST_LENGTH)?MD_DIGEST_LENGTH:j; - MD_Init(&m); + if (!MD_Init(&m)) { + EVP_MD_CTX_cleanup(&m); + if (!do_not_lock) CRYPTO_w_unlock(CRYPTO_LOCK_RAND); + return; + } MD_Update(&m,local_md,MD_DIGEST_LENGTH); k=(st_idx+j)-STATE_SIZE; if (k > 0) @@ -470,7 +474,10 @@ /* num_ceil -= MD_DIGEST_LENGTH/2 */ j=(num >= MD_DIGEST_LENGTH/2)?MD_DIGEST_LENGTH/2:num; num-=j; - MD_Init(&m); + if (!MD_Init(&m)) { + EVP_MD_CTX_cleanup(&m); + return 0; + } #ifndef GETPID_IS_MEANINGLESS if (curr_pid) /* just in the first iteration to save time */ { @@ -512,7 +519,10 @@ } } - MD_Init(&m); + if (!MD_Init(&m)) { + EVP_MD_CTX_cleanup(&m); + return 0; + } MD_Update(&m,(unsigned char *)&(md_c[0]),sizeof(md_c)); MD_Update(&m,local_md,MD_DIGEST_LENGTH); if (lock)