diff --git a/libraries/libldap/pagectrl.c b/libraries/libldap/pagectrl.c index 40093cb6fd..c6f1c4ab75 100644 --- a/libraries/libldap/pagectrl.c +++ b/libraries/libldap/pagectrl.c @@ -65,8 +65,9 @@ ldap_create_page_control_value( if ( ld == NULL || value == NULL || pagesize < 1 || pagesize > LDAP_MAXINT ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; + if ( ld ) + ld->ld_errno = LDAP_PARAM_ERROR; + return LDAP_PARAM_ERROR; } assert( LDAP_VALID( ld ) ); @@ -195,8 +196,9 @@ ldap_parse_pageresponse_control( ber_int_t count; if ( ld == NULL || ctrl == NULL || cookie == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; + if ( ld ) + ld->ld_errno = LDAP_PARAM_ERROR; + return LDAP_PARAM_ERROR; } /* Create a BerElement from the berval returned in the control. */ diff --git a/libraries/libldap/sortctrl.c b/libraries/libldap/sortctrl.c index 3875387e21..b4e1f8591e 100644 --- a/libraries/libldap/sortctrl.c +++ b/libraries/libldap/sortctrl.c @@ -297,8 +297,9 @@ ldap_create_sort_control_value( ber_tag_t tag; if ( ld == NULL || keyList == NULL || value == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; + if ( ld ) + ld->ld_errno = LDAP_PARAM_ERROR; + return LDAP_PARAM_ERROR; } assert( LDAP_VALID( ld ) ); @@ -496,8 +497,7 @@ ldap_parse_sortresponse_control( ber_len_t berLen; if (ld == NULL) { - ld->ld_errno = LDAP_PARAM_ERROR; - return(ld->ld_errno); + return LDAP_PARAM_ERROR; } if (ctrl == NULL) { diff --git a/libraries/libldap/vlvctrl.c b/libraries/libldap/vlvctrl.c index ab731007cd..86528c503c 100644 --- a/libraries/libldap/vlvctrl.c +++ b/libraries/libldap/vlvctrl.c @@ -95,8 +95,9 @@ ldap_create_vlv_control_value( BerElement *ber; if ( ld == NULL || vlvinfop == NULL || value == NULL ) { - ld->ld_errno = LDAP_PARAM_ERROR; - return ld->ld_errno; + if ( ld ) + ld->ld_errno = LDAP_PARAM_ERROR; + return LDAP_PARAM_ERROR; } assert( LDAP_VALID( ld ) );