don't care about empty matched/text #ifdef LDAP_NULL_IS_NULL

This commit is contained in:
Pierangelo Masarati 2005-11-20 01:59:26 +00:00
parent 01bea97a26
commit 4852bf8a58
4 changed files with 28 additions and 2 deletions

View file

@ -866,6 +866,16 @@ retry:;
default: default:
rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
&match, &text, NULL, NULL, 1 ); &match, &text, NULL, NULL, 1 );
#ifndef LDAP_NULL_IS_NULL
if ( match != NULL && match[ 0 ] == '\0' ) {
ldap_memfree( match );
match = NULL;
}
if ( text != NULL && text[ 0 ] == '\0' ) {
ldap_memfree( text );
text = NULL;
}
#endif /* LDAP_NULL_IS_NULL */
rs->sr_text = text; rs->sr_text = text;
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
rs->sr_err = rc; rs->sr_err = rc;

View file

@ -135,6 +135,7 @@ retry:
(char **)&rs->sr_matched, (char **)&rs->sr_matched,
(char **)&rs->sr_text, (char **)&rs->sr_text,
NULL, NULL, 0 ); NULL, NULL, 0 );
#ifndef LDAP_NULL_IS_NULL
if ( rs->sr_matched && rs->sr_matched[ 0 ] == '\0' ) { if ( rs->sr_matched && rs->sr_matched[ 0 ] == '\0' ) {
free( (char *)rs->sr_matched ); free( (char *)rs->sr_matched );
rs->sr_matched = NULL; rs->sr_matched = NULL;
@ -143,6 +144,7 @@ retry:
free( (char *)rs->sr_text ); free( (char *)rs->sr_text );
rs->sr_text = NULL; rs->sr_text = NULL;
} }
#endif /* LDAP_NULL_IS_NULL */
if ( rc == LDAP_SUCCESS ) { if ( rc == LDAP_SUCCESS ) {
if ( rs->sr_err == LDAP_SUCCESS ) { if ( rs->sr_err == LDAP_SUCCESS ) {
struct berval newpw; struct berval newpw;

View file

@ -402,13 +402,22 @@ retry:
} }
if ( match.bv_val != NULL ) { if ( match.bv_val != NULL ) {
#ifndef LDAP_NULL_IS_NULL
if ( match.bv_val[ 0 ] == '\0' ) { if ( match.bv_val[ 0 ] == '\0' ) {
LDAP_FREE( match.bv_val ); LDAP_FREE( match.bv_val );
BER_BVZERO( &match ); BER_BVZERO( &match );
} else { } else
#endif /* LDAP_NULL_IS_NULL */
{
match.bv_len = strlen( match.bv_val ); match.bv_len = strlen( match.bv_val );
} }
} }
#ifndef LDAP_NULL_IS_NULL
if ( rs->sr_text != NULL && rs->sr_text[ 0 ] == '\0' ) {
LDAP_FREE( (char *)rs->sr_text );
rs->sr_text = NULL;
}
#endif /* LDAP_NULL_IS_NULL */
/* cleanup */ /* cleanup */
if ( references ) { if ( references ) {

View file

@ -595,11 +595,14 @@ really_bad:;
/* massage matchedDN if need be */ /* massage matchedDN if need be */
if ( candidates[ i ].sr_matched != NULL ) { if ( candidates[ i ].sr_matched != NULL ) {
#ifndef LDAP_NULL_IS_NULL
if ( candidates[ i ].sr_matched[ 0 ] == '\0' ) { if ( candidates[ i ].sr_matched[ 0 ] == '\0' ) {
ldap_memfree( (char *)candidates[ i ].sr_matched ); ldap_memfree( (char *)candidates[ i ].sr_matched );
candidates[ i ].sr_matched = NULL; candidates[ i ].sr_matched = NULL;
} else { } else
#endif /* LDAP_NULL_IS_NULL */
{
struct berval match, mmatch; struct berval match, mmatch;
ber_str2bv( candidates[ i ].sr_matched, ber_str2bv( candidates[ i ].sr_matched,
@ -622,12 +625,14 @@ really_bad:;
} }
} }
#ifndef LDAP_NULL_IS_NULL
/* just get rid of the error message, if any */ /* just get rid of the error message, if any */
if ( candidates[ i ].sr_text && candidates[ i ].sr_text[ 0 ] == '\0' ) if ( candidates[ i ].sr_text && candidates[ i ].sr_text[ 0 ] == '\0' )
{ {
ldap_memfree( (char *)candidates[ i ].sr_text ); ldap_memfree( (char *)candidates[ i ].sr_text );
candidates[ i ].sr_text = NULL; candidates[ i ].sr_text = NULL;
} }
#endif /* LDAP_NULL_IS_NULL */
/* add references to array */ /* add references to array */
if ( references ) { if ( references ) {