LDAP_CONST char *
 ldap_syntax2name( LDAPSyntax * syn )
 {
+       if (!syn) return NULL;
        return( syn->syn_oid );
 }
 
 LDAP_CONST char *
 ldap_matchingrule2name( LDAPMatchingRule * mr )
 {
+       if (!mr) return NULL;
        return( choose_name( mr->mr_names, mr->mr_oid ) );
 }
 
 LDAP_CONST char *
 ldap_matchingruleuse2name( LDAPMatchingRuleUse * mru )
 {
+       if (!mru) return NULL;
        return( choose_name( mru->mru_names, mru->mru_oid ) );
 }
 
 LDAP_CONST char *
 ldap_attributetype2name( LDAPAttributeType * at )
 {
+       if (!at) return NULL;
        return( choose_name( at->at_names, at->at_oid ) );
 }
 
 LDAP_CONST char *
 ldap_objectclass2name( LDAPObjectClass * oc )
 {
+       if (!oc) return NULL;
        return( choose_name( oc->oc_names, oc->oc_oid ) );
 }
 
 LDAP_CONST char *
 ldap_contentrule2name( LDAPContentRule * cr )
 {
+       if (!cr) return NULL;
        return( choose_name( cr->cr_names, cr->cr_oid ) );
 }
 
 LDAP_CONST char *
 ldap_nameform2name( LDAPNameForm * nf )
 {
+       if (!nf) return NULL;
        return( choose_name( nf->nf_names, nf->nf_oid ) );
 }
 
 LDAP_CONST char *
 ldap_structurerule2name( LDAPStructureRule * sr )
 {
+       if (!sr) return NULL;
        return( choose_name( sr->sr_names, NULL ) );
 }
 
 ldap_syntax2bv( LDAPSyntax * syn, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !syn || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_matchingrule2bv( LDAPMatchingRule * mr, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !mr || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_matchingruleuse2bv( LDAPMatchingRuleUse * mru, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !mru || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_objectclass2bv( LDAPObjectClass * oc, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !oc || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_contentrule2bv( LDAPContentRule * cr, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !cr || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_structurerule2bv( LDAPStructureRule * sr, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !sr || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_nameform2bv( LDAPNameForm * nf, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !nf || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 ldap_attributetype2bv(  LDAPAttributeType * at, struct berval *bv )
 {
        safe_string * ss;
-       
+
+       if ( !at || !bv )
+               return NULL;
+
        ss = new_safe_string(256);
        if ( !ss )
                return NULL;
 void
 ldap_syntax_free( LDAPSyntax * syn )
 {
+       if ( !syn ) return;
        LDAP_FREE(syn->syn_oid);
        if (syn->syn_names) LDAP_VFREE(syn->syn_names);
        if (syn->syn_desc) LDAP_FREE(syn->syn_desc);
 void
 ldap_matchingrule_free( LDAPMatchingRule * mr )
 {
+       if (!mr) return;
        LDAP_FREE(mr->mr_oid);
        if (mr->mr_names) LDAP_VFREE(mr->mr_names);
        if (mr->mr_desc) LDAP_FREE(mr->mr_desc);
 void
 ldap_matchingruleuse_free( LDAPMatchingRuleUse * mru )
 {
+       if (!mru) return;
        LDAP_FREE(mru->mru_oid);
        if (mru->mru_names) LDAP_VFREE(mru->mru_names);
        if (mru->mru_desc) LDAP_FREE(mru->mru_desc);
 void
 ldap_attributetype_free(LDAPAttributeType * at)
 {
+       if (!at) return;
        LDAP_FREE(at->at_oid);
        if (at->at_names) LDAP_VFREE(at->at_names);
        if (at->at_desc) LDAP_FREE(at->at_desc);
 void
 ldap_objectclass_free(LDAPObjectClass * oc)
 {
+       if (!oc) return;
        LDAP_FREE(oc->oc_oid);
        if (oc->oc_names) LDAP_VFREE(oc->oc_names);
        if (oc->oc_desc) LDAP_FREE(oc->oc_desc);
 void
 ldap_contentrule_free(LDAPContentRule * cr)
 {
+       if (!cr) return;
        LDAP_FREE(cr->cr_oid);
        if (cr->cr_names) LDAP_VFREE(cr->cr_names);
        if (cr->cr_desc) LDAP_FREE(cr->cr_desc);
 void
 ldap_structurerule_free(LDAPStructureRule * sr)
 {
+       if (!sr) return;
        if (sr->sr_names) LDAP_VFREE(sr->sr_names);
        if (sr->sr_desc) LDAP_FREE(sr->sr_desc);
        if (sr->sr_nameform) LDAP_FREE(sr->sr_nameform);
 void
 ldap_nameform_free(LDAPNameForm * nf)
 {
+       if (!nf) return;
        LDAP_FREE(nf->nf_oid);
        if (nf->nf_names) LDAP_VFREE(nf->nf_names);
        if (nf->nf_desc) LDAP_FREE(nf->nf_desc);