diff options
author | Rich Salz <rsalz@openssl.org> | 2018-04-26 14:02:24 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2018-04-26 14:02:24 -0400 |
commit | fe1128dc2a6e7aae9010cf6595c78245e0eefd46 (patch) | |
tree | de62e713f375adaefd7e6bfd8491575c0fc530a3 /crypto/lhash/lhash.c | |
parent | 74a8acbdfb2c7f398d1ae2fe914cd32b437f6df4 (diff) |
Fix last(?) batch of malloc-NULL places
Add a script to find them in the future
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/6103)
Diffstat (limited to 'crypto/lhash/lhash.c')
-rw-r--r-- | crypto/lhash/lhash.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/lhash/lhash.c b/crypto/lhash/lhash.c index 38c084d115..116274b024 100644 --- a/crypto/lhash/lhash.c +++ b/crypto/lhash/lhash.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <openssl/crypto.h> #include <openssl/lhash.h> +#include <openssl/err.h> #include "lhash_lcl.h" /* @@ -45,8 +46,14 @@ OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c) { OPENSSL_LHASH *ret; - if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) + if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) { + /* + * Do not set the error code, because the ERR code uses LHASH + * and we want to avoid possible endless error loop. + * CRYPTOerr(CRYPTO_F_OPENSSL_LH_NEW, ERR_R_MALLOC_FAILURE); + */ return NULL; + } if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL) goto err; ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c); |