mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-21 07:09:34 -05:00
Plug unlikely memleak (coverity)
This commit is contained in:
parent
a69da18849
commit
08f5aca7db
2 changed files with 21 additions and 10 deletions
|
|
@ -266,16 +266,22 @@ ldap_pvt_thread_pool_init_q (
|
||||||
max_threads = LDAP_MAXTHR;
|
max_threads = LDAP_MAXTHR;
|
||||||
|
|
||||||
rc = ldap_pvt_thread_mutex_init(&pool->ltp_mutex);
|
rc = ldap_pvt_thread_mutex_init(&pool->ltp_mutex);
|
||||||
if (rc != 0)
|
if (rc != 0) {
|
||||||
|
fail:
|
||||||
|
for (i=0; i<numqs; i++)
|
||||||
|
LDAP_FREE(pool->ltp_wqs[i]->ltp_free);
|
||||||
|
LDAP_FREE(pool->ltp_wqs);
|
||||||
|
LDAP_FREE(pool);
|
||||||
return(rc);
|
return(rc);
|
||||||
|
}
|
||||||
|
|
||||||
rc = ldap_pvt_thread_cond_init(&pool->ltp_cond);
|
rc = ldap_pvt_thread_cond_init(&pool->ltp_cond);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return(rc);
|
goto fail;
|
||||||
|
|
||||||
rc = ldap_pvt_thread_cond_init(&pool->ltp_pcond);
|
rc = ldap_pvt_thread_cond_init(&pool->ltp_pcond);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
return(rc);
|
goto fail;
|
||||||
|
|
||||||
rem_thr = max_threads % numqs;
|
rem_thr = max_threads % numqs;
|
||||||
rem_pend = max_pending % numqs;
|
rem_pend = max_pending % numqs;
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ struct berval * UTF8bvnormalize(
|
||||||
void *ctx )
|
void *ctx )
|
||||||
{
|
{
|
||||||
int i, j, len, clen, outpos, ucsoutlen, outsize, last;
|
int i, j, len, clen, outpos, ucsoutlen, outsize, last;
|
||||||
|
int didnewbv = 0;
|
||||||
char *out, *outtmp, *s;
|
char *out, *outtmp, *s;
|
||||||
ac_uint4 *ucs, *p, *ucsout;
|
ac_uint4 *ucs, *p, *ucsout;
|
||||||
|
|
||||||
|
|
@ -132,6 +133,7 @@ struct berval * UTF8bvnormalize(
|
||||||
if ( !newbv ) {
|
if ( !newbv ) {
|
||||||
newbv = ber_memalloc_x( sizeof(struct berval), ctx );
|
newbv = ber_memalloc_x( sizeof(struct berval), ctx );
|
||||||
if ( !newbv ) return NULL;
|
if ( !newbv ) return NULL;
|
||||||
|
didnewbv = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should first check to see if string is already in proper
|
/* Should first check to see if string is already in proper
|
||||||
|
|
@ -145,6 +147,9 @@ struct berval * UTF8bvnormalize(
|
||||||
outsize = len + 7;
|
outsize = len + 7;
|
||||||
out = (char *) ber_memalloc_x( outsize, ctx );
|
out = (char *) ber_memalloc_x( outsize, ctx );
|
||||||
if ( out == NULL ) {
|
if ( out == NULL ) {
|
||||||
|
fail:
|
||||||
|
if ( didnewbv )
|
||||||
|
ber_memfree_x( newbv, ctx );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
outpos = 0;
|
outpos = 0;
|
||||||
|
|
@ -171,7 +176,7 @@ struct berval * UTF8bvnormalize(
|
||||||
outsize = len + 7;
|
outsize = len + 7;
|
||||||
out = (char *) ber_memalloc_x( outsize, ctx );
|
out = (char *) ber_memalloc_x( outsize, ctx );
|
||||||
if ( out == NULL ) {
|
if ( out == NULL ) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
outpos = i - 1;
|
outpos = i - 1;
|
||||||
memcpy(out, s, outpos);
|
memcpy(out, s, outpos);
|
||||||
|
|
@ -180,7 +185,7 @@ struct berval * UTF8bvnormalize(
|
||||||
outsize = len + 7;
|
outsize = len + 7;
|
||||||
out = (char *) ber_memalloc_x( outsize, ctx );
|
out = (char *) ber_memalloc_x( outsize, ctx );
|
||||||
if ( out == NULL ) {
|
if ( out == NULL ) {
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
outpos = 0;
|
outpos = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
@ -189,7 +194,7 @@ struct berval * UTF8bvnormalize(
|
||||||
p = ucs = ber_memalloc_x( len * sizeof(*ucs), ctx );
|
p = ucs = ber_memalloc_x( len * sizeof(*ucs), ctx );
|
||||||
if ( ucs == NULL ) {
|
if ( ucs == NULL ) {
|
||||||
ber_memfree_x(out, ctx);
|
ber_memfree_x(out, ctx);
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert character before first non-ascii to ucs-4 */
|
/* convert character before first non-ascii to ucs-4 */
|
||||||
|
|
@ -207,7 +212,7 @@ struct berval * UTF8bvnormalize(
|
||||||
if ( clen == 0 ) {
|
if ( clen == 0 ) {
|
||||||
ber_memfree_x( ucs, ctx );
|
ber_memfree_x( ucs, ctx );
|
||||||
ber_memfree_x( out, ctx );
|
ber_memfree_x( out, ctx );
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
if ( clen == 1 ) {
|
if ( clen == 1 ) {
|
||||||
/* ascii */
|
/* ascii */
|
||||||
|
|
@ -219,7 +224,7 @@ struct berval * UTF8bvnormalize(
|
||||||
if ( (s[i] & 0xc0) != 0x80 ) {
|
if ( (s[i] & 0xc0) != 0x80 ) {
|
||||||
ber_memfree_x( ucs, ctx );
|
ber_memfree_x( ucs, ctx );
|
||||||
ber_memfree_x( out, ctx );
|
ber_memfree_x( out, ctx );
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
*p <<= 6;
|
*p <<= 6;
|
||||||
*p |= s[i] & 0x3f;
|
*p |= s[i] & 0x3f;
|
||||||
|
|
@ -251,7 +256,7 @@ struct berval * UTF8bvnormalize(
|
||||||
ber_memfree_x( ucsout, ctx );
|
ber_memfree_x( ucsout, ctx );
|
||||||
ber_memfree_x( ucs, ctx );
|
ber_memfree_x( ucs, ctx );
|
||||||
ber_memfree_x( out, ctx );
|
ber_memfree_x( out, ctx );
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
out = outtmp;
|
out = outtmp;
|
||||||
}
|
}
|
||||||
|
|
@ -275,7 +280,7 @@ struct berval * UTF8bvnormalize(
|
||||||
if (outtmp == NULL) {
|
if (outtmp == NULL) {
|
||||||
ber_memfree_x( ucs, ctx );
|
ber_memfree_x( ucs, ctx );
|
||||||
ber_memfree_x( out, ctx );
|
ber_memfree_x( out, ctx );
|
||||||
return NULL;
|
goto fail;
|
||||||
}
|
}
|
||||||
out = outtmp;
|
out = outtmp;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue