ITS#9876 Coverity fixes: plug memleaks

This commit is contained in:
Howard Chu 2022-07-05 03:49:34 +01:00
parent b9173d3031
commit 78618653c2
4 changed files with 15 additions and 13 deletions

View file

@ -193,6 +193,7 @@ ldap_parse_derefresponse_control(
dr = LDAP_CALLOC( 1, sizeof(LDAPDerefRes) );
if ( dr == NULL ) {
ldap_derefresponse_free( drhead );
ber_free( ber, 1 );
*drp2 = NULL;
ld->ld_errno = LDAP_NO_MEMORY;
return ld->ld_errno;

View file

@ -729,7 +729,8 @@ ldif_open(
if ( fp ) {
lfp = ber_memalloc( sizeof( LDIFFP ));
if ( lfp == NULL ) {
return NULL;
fclose( fp );
return NULL;
}
lfp->fp = fp;
lfp->prev = NULL;

View file

@ -44,7 +44,7 @@ ldap_turn(
{
#ifdef LDAP_EXOP_X_TURN
BerElement *turnvalber = NULL;
struct berval *turnvalp = NULL;
struct berval turnval;
int rc;
turnvalber = ber_alloc_t( LBER_USE_DER );
@ -53,10 +53,10 @@ ldap_turn(
} else {
ber_printf( turnvalber, "{s}", identifier );
}
ber_flatten( turnvalber, &turnvalp );
ber_flatten2( turnvalber, &turnval, 0 );
rc = ldap_extended_operation( ld, LDAP_EXOP_X_TURN,
turnvalp, sctrls, cctrls, msgidp );
&turnval, sctrls, cctrls, msgidp );
ber_free( turnvalber, 1 );
return rc;
#else
@ -74,7 +74,7 @@ ldap_turn_s(
{
#ifdef LDAP_EXOP_X_TURN
BerElement *turnvalber = NULL;
struct berval *turnvalp = NULL;
struct berval turnval;
int rc;
turnvalber = ber_alloc_t( LBER_USE_DER );
@ -83,10 +83,10 @@ ldap_turn_s(
} else {
ber_printf( turnvalber, "{s}", identifier );
}
ber_flatten( turnvalber, &turnvalp );
ber_flatten2( turnvalber, &turnval, 0 );
rc = ldap_extended_operation_s( ld, LDAP_EXOP_X_TURN,
turnvalp, sctrls, cctrls, NULL, NULL );
&turnval, sctrls, cctrls, NULL, NULL );
ber_free( turnvalber, 1 );
return rc;
#else

View file

@ -68,7 +68,7 @@ ldap_txn_end(
{
int rc;
BerElement *txnber = NULL;
struct berval *txnval = NULL;
struct berval txnval;
assert( txnid != NULL );
@ -80,10 +80,10 @@ ldap_txn_end(
ber_printf( txnber, "{bON}", commit, txnid );
}
ber_flatten( txnber, &txnval );
ber_flatten2( txnber, &txnval, 0 );
rc = ldap_extended_operation( ld, LDAP_EXOP_TXN_END,
txnval, sctrls, cctrls, msgidp );
&txnval, sctrls, cctrls, msgidp );
ber_free( txnber, 1 );
return rc;
@ -100,7 +100,7 @@ ldap_txn_end_s(
{
int rc;
BerElement *txnber = NULL;
struct berval *txnval = NULL;
struct berval txnval;
struct berval *retdata = NULL;
if ( retidp != NULL ) *retidp = -1;
@ -113,10 +113,10 @@ ldap_txn_end_s(
ber_printf( txnber, "{bON}", commit, txnid );
}
ber_flatten( txnber, &txnval );
ber_flatten2( txnber, &txnval, 0 );
rc = ldap_extended_operation_s( ld, LDAP_EXOP_TXN_END,
txnval, sctrls, cctrls, NULL, &retdata );
&txnval, sctrls, cctrls, NULL, &retdata );
ber_free( txnber, 1 );