From: Kurt Zeilenga Date: Fri, 21 May 1999 03:56:17 +0000 (+0000) Subject: Assert pointer args X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~25 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9c2ebd1f4244aa98b29d9391816003f1f62817e2;p=openldap Assert pointer args --- diff --git a/libraries/libldap/result.c b/libraries/libldap/result.c index 68057ab7b4..48fdcc2c22 100644 --- a/libraries/libldap/result.c +++ b/libraries/libldap/result.c @@ -61,6 +61,20 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, { LDAPMessage *lm, *lastlm, *nextlm; + assert( ld != NULL ); + assert( result != NULL ); + + Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); + + if( ld == NULL ) { + return -1; + } + + if( result == NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + return -1; + } + /* * First, look through the list of responses we have received on * this association and see if the response we're interested in @@ -68,8 +82,6 @@ ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout, * wait until it arrives or timeout occurs. */ - Debug( LDAP_DEBUG_TRACE, "ldap_result\n", 0, 0, 0 ); - *result = NULLMSG; lastlm = NULLMSG; for ( lm = ld->ld_responses; lm != NULLMSG; lm = nextlm ) { @@ -144,6 +156,9 @@ wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout, LDAPConn *lc, *nextlc; #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ + assert( ld != NULL ); + assert( result != NULL ); + #ifdef LDAP_DEBUG if ( timeout == NULL ) { Debug( LDAP_DEBUG_TRACE, "wait4msg (infinite timeout)\n", @@ -275,13 +290,20 @@ try_read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, BerElement tmpber; int rc, refer_cnt, hadref, simple_request; unsigned long lderr; + + assert( ld != NULL ); + assert( lc != NULL ); ber = &lc->lconn_ber; + #else + assert( ld != NULL ); + ber = &ld->ld_ber; #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */ Debug( LDAP_DEBUG_TRACE, "read1msg\n", 0, 0, 0 ); + #if 0 ber_init_w_nullc( &ber, 0 ); ldap_set_ber_options( ld, &ber ); @@ -607,6 +629,8 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) fd_set readfds; static int tblsize; + assert( ld != NULL ); + if ( tblsize == 0 ) { #ifdef HAVE_SYSCONF tblsize = sysconf( _SC_OPEN_MAX ); @@ -634,13 +658,17 @@ ldap_select1( LDAP *ld, struct timeval *timeout ) int ldap_msgtype( LDAPMessage *lm ) { - return( lm ? lm->lm_msgtype : -1 ); + assert( lm != NULL ); + return ( lm == NULL ) ? lm->lm_msgtype : -1; } + int ldap_msgid( LDAPMessage *lm ) { - return( lm ? lm->lm_msgid : -1 ); + assert( lm != NULL ); + + return ( lm == NULL ) ? lm->lm_msgid : -1; } @@ -650,6 +678,8 @@ ldap_msgfree( LDAPMessage *lm ) LDAPMessage *next; int type = 0; + assert( lm != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_msgfree\n", 0, 0, 0 ); for ( ; lm != NULLMSG; lm = next ) { @@ -672,6 +702,8 @@ ldap_msgdelete( LDAP *ld, int msgid ) { LDAPMessage *lm, *prev; + assert( ld != NULL ); + Debug( LDAP_DEBUG_TRACE, "ldap_msgdelete\n", 0, 0, 0 ); prev = NULLMSG;