You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by ka...@apache.org on 2007/09/05 14:18:38 UTC
svn commit: r572935 - in /webservices/rampart/trunk/c/src:
omxmlsec/openssl/pkey.c omxmlsec/x509_cert.c util/rampart_token_processor.c
Author: kaushalye
Date: Wed Sep 5 05:18:33 2007
New Revision: 572935
URL: http://svn.apache.org/viewvc?rev=572935&view=rev
Log:
Introduced a ref counter for public/private keys
Memory leak fixed
Modified:
webservices/rampart/trunk/c/src/omxmlsec/openssl/pkey.c
webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c
webservices/rampart/trunk/c/src/util/rampart_token_processor.c
Modified: webservices/rampart/trunk/c/src/omxmlsec/openssl/pkey.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/openssl/pkey.c?rev=572935&r1=572934&r2=572935&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/openssl/pkey.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/openssl/pkey.c Wed Sep 5 05:18:33 2007
@@ -39,6 +39,7 @@
EVP_PKEY *key;
axis2_char_t *name;
int type;
+ int ref;
};
@@ -57,7 +58,7 @@
pkey->key = NULL;
pkey->name = NULL ;
pkey->type = OPENSSL_PKEY_TYPE_UNKNOWN;
-
+ pkey->ref = 0;
return pkey;
}
@@ -222,6 +223,17 @@
return AXIS2_SUCCESS;
}
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+openssl_pkey_increment_ref(
+ openssl_pkey_t *pkey,
+ const axutil_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ pkey->ref++;
+ return AXIS2_SUCCESS;
+}
+
+
axis2_status_t AXIS2_CALL
openssl_pkey_free(
openssl_pkey_t *pkey,
@@ -230,11 +242,15 @@
{
AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ /*We do not FREE. If somebody still need this*/
+ if(--(pkey->ref) > 0){
+ return AXIS2_SUCCESS ;
+ }
if (pkey->key)
{
- /*AXIS2_FREE(env->allocator, pkey->key);*/
- EVP_PKEY_free(pkey->key);
+ EVP_PKEY_free(pkey->key);
pkey->key = NULL;
}
if (pkey->name)
Modified: webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c?rev=572935&r1=572934&r2=572935&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/x509_cert.c Wed Sep 5 05:18:33 2007
@@ -290,11 +290,12 @@
const axutil_env_t *env,
openssl_pkey_t *public_key)
{
- if(x509_cert->public_key)
+ /*if(x509_cert->public_key)
{
openssl_pkey_free(x509_cert->public_key, env);
x509_cert->public_key = NULL;
- }
+ }*/
+ openssl_pkey_increment_ref(public_key, env);
x509_cert->public_key = public_key;
return AXIS2_SUCCESS;
}
Modified: webservices/rampart/trunk/c/src/util/rampart_token_processor.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_token_processor.c?rev=572935&r1=572934&r2=572935&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_token_processor.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_token_processor.c Wed Sep 5 05:18:33 2007
@@ -99,6 +99,9 @@
oxs_x509_cert_copy_to(_cert, env, cert);
+ oxs_x509_cert_free(_cert, env);
+ _cert = NULL;
+
return status;
}