You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by br...@apache.org on 2014/06/26 20:51:07 UTC
svn commit: r1605876 -
/subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c
Author: breser
Date: Thu Jun 26 18:51:06 2014
New Revision: 1605876
URL: http://svn.apache.org/r1605876
Log:
On svn-auth-x509 branch, fix a memory leak.
* subversion/libsvn_subr/x509parse.c
(x509_get_name): Add a pool argument and use it for allocation rather than a
malloc which we never bother to free.
(svn_x509_parse_cert): Add pool argument to x509_get_name() calls.
Modified:
subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c
Modified: subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c
URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c?rev=1605876&r1=1605875&r2=1605876&view=diff
==============================================================================
--- subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c (original)
+++ subversion/branches/svn-auth-x509/subversion/libsvn_subr/x509parse.c Thu Jun 26 18:51:06 2014
@@ -260,7 +260,8 @@ x509_get_alg(const unsigned char **p, co
* AttributeValue ::= ANY DEFINED BY AttributeType
*/
static svn_error_t *
-x509_get_name(const unsigned char **p, const unsigned char *end, x509_name * cur)
+x509_get_name(const unsigned char **p, const unsigned char *end,
+ x509_name * cur, apr_pool_t *result_pool)
{
svn_error_t *err;
int len;
@@ -333,12 +334,12 @@ x509_get_name(const unsigned char **p, c
if (*p == end2)
return SVN_NO_ERROR;
- cur->next = (x509_name *) malloc(sizeof(x509_name));
+ cur->next = (x509_name *) apr_palloc(result_pool, sizeof(x509_name));
if (cur->next == NULL)
return SVN_NO_ERROR;
- return svn_error_trace(x509_get_name(p, end2, cur->next));
+ return svn_error_trace(x509_get_name(p, end2, cur->next, result_pool));
}
/*
@@ -650,7 +651,7 @@ svn_x509_parse_cert(apr_hash_t **certinf
if (err)
return svn_error_create(SVN_ERR_X509_CERT_INVALID_FORMAT, err, NULL);
- SVN_ERR(x509_get_name(&p, p + len, &crt->issuer));
+ SVN_ERR(x509_get_name(&p, p + len, &crt->issuer, scratch_pool));
crt->issuer_raw.len = (int) (p - crt->issuer_raw.p);
@@ -671,7 +672,7 @@ svn_x509_parse_cert(apr_hash_t **certinf
if (err)
return svn_error_create(SVN_ERR_X509_CERT_INVALID_FORMAT, err, NULL);
- SVN_ERR(x509_get_name(&p, p + len, &crt->subject));
+ SVN_ERR(x509_get_name(&p, p + len, &crt->subject, scratch_pool));
crt->subject_raw.len = (int) (p - crt->subject_raw.p);