From: Pierangelo Masarati Date: Sun, 20 Nov 2005 01:59:26 +0000 (+0000) Subject: don't care about empty matched/text #ifdef LDAP_NULL_IS_NULL X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~767 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4852bf8a580f5ce3baae7795396b4265c110db8a;p=openldap don't care about empty matched/text #ifdef LDAP_NULL_IS_NULL --- diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index 266136dc3f..6d7899e44d 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -866,6 +866,16 @@ retry:; default: rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &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; if ( rc != LDAP_SUCCESS ) { rs->sr_err = rc; diff --git a/servers/slapd/back-ldap/extended.c b/servers/slapd/back-ldap/extended.c index 8eef4d317e..dae58547f0 100644 --- a/servers/slapd/back-ldap/extended.c +++ b/servers/slapd/back-ldap/extended.c @@ -135,6 +135,7 @@ retry: (char **)&rs->sr_matched, (char **)&rs->sr_text, NULL, NULL, 0 ); +#ifndef LDAP_NULL_IS_NULL if ( rs->sr_matched && rs->sr_matched[ 0 ] == '\0' ) { free( (char *)rs->sr_matched ); rs->sr_matched = NULL; @@ -143,6 +144,7 @@ retry: free( (char *)rs->sr_text ); rs->sr_text = NULL; } +#endif /* LDAP_NULL_IS_NULL */ if ( rc == LDAP_SUCCESS ) { if ( rs->sr_err == LDAP_SUCCESS ) { struct berval newpw; diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 510a4bba98..e1a8880086 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -402,13 +402,22 @@ retry: } if ( match.bv_val != NULL ) { +#ifndef LDAP_NULL_IS_NULL if ( match.bv_val[ 0 ] == '\0' ) { LDAP_FREE( match.bv_val ); BER_BVZERO( &match ); - } else { + } else +#endif /* LDAP_NULL_IS_NULL */ + { 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 */ if ( references ) { diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index dbcab08c8b..fb0c813c60 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -595,11 +595,14 @@ really_bad:; /* massage matchedDN if need be */ if ( candidates[ i ].sr_matched != NULL ) { +#ifndef LDAP_NULL_IS_NULL if ( candidates[ i ].sr_matched[ 0 ] == '\0' ) { ldap_memfree( (char *)candidates[ i ].sr_matched ); candidates[ i ].sr_matched = NULL; - } else { + } else +#endif /* LDAP_NULL_IS_NULL */ + { struct berval match, mmatch; 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 */ if ( candidates[ i ].sr_text && candidates[ i ].sr_text[ 0 ] == '\0' ) { ldap_memfree( (char *)candidates[ i ].sr_text ); candidates[ i ].sr_text = NULL; } +#endif /* LDAP_NULL_IS_NULL */ /* add references to array */ if ( references ) {