summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2001-09-10 18:50:09 +0000
committerBodo Möller <bodo@openssl.org>2001-09-10 18:50:09 +0000
commit9f29ec47216b8c5ad6812f1bbd998076c4c5babf (patch)
treec9826c63437ad89432e88d9eec3c7501ec97efdb /crypto/err
parentb9a20b50572731efa916df5a06e705bef46c5a3a (diff)
fix memory leak (I think)
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 6d7f9b9c22..8e329f028b 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -216,13 +216,13 @@ static ERR_STRING_DATA ERR_str_reasons[]=
struct st_ERR_FNS
{
/* Works on the "error_hash" string table */
- LHASH *(*cb_err_get)(void);
+ LHASH *(*cb_err_get)(int create);
void (*cb_err_del)(void);
ERR_STRING_DATA *(*cb_err_get_item)(const ERR_STRING_DATA *);
ERR_STRING_DATA *(*cb_err_set_item)(ERR_STRING_DATA *);
ERR_STRING_DATA *(*cb_err_del_item)(ERR_STRING_DATA *);
/* Works on the "thread_hash" error-state table */
- LHASH *(*cb_thread_get)(void);
+ LHASH *(*cb_thread_get)(int create);
ERR_STATE *(*cb_thread_get_item)(const ERR_STATE *);
ERR_STATE *(*cb_thread_set_item)(ERR_STATE *);
void (*cb_thread_del_item)(const ERR_STATE *);
@@ -231,12 +231,12 @@ struct st_ERR_FNS
};
/* Predeclarations of the "err_defaults" functions */
-static LHASH *int_err_get(void);
+static LHASH *int_err_get(int create);
static void int_err_del(void);
static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *);
static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *);
static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *);
-static LHASH *int_thread_get(void);
+static LHASH *int_thread_get(int create);
static ERR_STATE *int_thread_get_item(const ERR_STATE *);
static ERR_STATE *int_thread_set_item(ERR_STATE *);
static void int_thread_del_item(const ERR_STATE *);
@@ -323,13 +323,17 @@ static unsigned long get_error_values(int inc,const char **file,int *line,
/* The internal functions used in the "err_defaults" implementation */
-static LHASH *int_err_get(void)
+static LHASH *int_err_get(int create)
{
LHASH *ret = NULL;
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
- if (!int_error_hash)
+ if (!int_error_hash && create)
+ {
+ CRYPTO_push_info("int_err_get (err.c)");
int_error_hash = lh_new(err_hash, err_cmp);
+ CRYPTO_pop_info();
+ }
if (int_error_hash)
ret = int_error_hash;
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
@@ -354,7 +358,7 @@ static ERR_STRING_DATA *int_err_get_item(const ERR_STRING_DATA *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(err_get)();
+ hash = ERRFN(err_get)(0);
if (!hash)
return NULL;
@@ -371,7 +375,7 @@ static ERR_STRING_DATA *int_err_set_item(ERR_STRING_DATA *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(err_get)();
+ hash = ERRFN(err_get)(1);
if (!hash)
return NULL;
@@ -388,7 +392,7 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(err_get)();
+ hash = ERRFN(err_get)(0);
if (!hash)
return NULL;
@@ -399,13 +403,17 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
return p;
}
-static LHASH *int_thread_get(void)
+static LHASH *int_thread_get(int create)
{
LHASH *ret = NULL;
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
- if (!int_thread_hash)
+ if (!int_thread_hash && create)
+ {
+ CRYPTO_push_info("int_thread_get (err.c)");
int_thread_hash = lh_new(pid_hash, pid_cmp);
+ CRYPTO_pop_info();
+ }
if (int_thread_hash)
ret = int_thread_hash;
CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
@@ -418,7 +426,7 @@ static ERR_STATE *int_thread_get_item(const ERR_STATE *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(thread_get)();
+ hash = ERRFN(thread_get)(0);
if (!hash)
return NULL;
@@ -435,7 +443,7 @@ static ERR_STATE *int_thread_set_item(ERR_STATE *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(thread_get)();
+ hash = ERRFN(thread_get)(1);
if (!hash)
return NULL;
@@ -452,7 +460,7 @@ static void int_thread_del_item(const ERR_STATE *d)
LHASH *hash;
err_fns_check();
- hash = ERRFN(thread_get)();
+ hash = ERRFN(thread_get)(0);
if (!hash)
return;
@@ -800,13 +808,13 @@ char *ERR_error_string(unsigned long e, char *ret)
LHASH *ERR_get_string_table(void)
{
err_fns_check();
- return ERRFN(err_get)();
+ return ERRFN(err_get)(0);
}
LHASH *ERR_get_err_state_table(void)
{
err_fns_check();
- return ERRFN(thread_get)();
+ return ERRFN(thread_get)(0);
}
const char *ERR_lib_error_string(unsigned long e)