[Date Prev][Date Next] [Chronological] [Thread] [Top]

segmentation fault:chunk_alloc ()



 I have a system of redhat 7.0.I use the ldap_api. When i use synchronous search and resove the entry,i meet the segmentation fault.It may be some memory malloced in the api routines , when I free them out of the api ,it cannot be freed correctly! Following is some of my program!


           /* search for entries with cn of "Babs Jensen", return all attrs  */
           if (( rc = ldap_search_s( ld, "ou=customers,dc=example,dc=com",
               LDAP_SCOPE_SUBTREE, "(objectclass=*)", NULL, 0, &res ))
               != LDAP_SUCCESS ) {
                   fprintf( stderr, "ldap_search_s: %s\n",ldap_err2string( rc ));
                   if ( res == NULL ) {
                           ldap_unbind( ld );
                           return 1;
                   }
           }

         printf("entry count:%d\n",ldap_count_entries(ld, res ));
		   
           /* step through each entry returned */
           for ( e = ldap_first_entry( ld, res ); e != NULL;e = ldap_next_entry( ld, e ) ) 
	       {
                   /* print its name */
                   dn = ldap_get_dn( ld, e );
                   printf( "dn: %s\n", dn );
                   ldap_memfree( dn );

                   /* print each attribute */
                   for ( a=ldap_first_attribute(ld,e,&ptr );  a!=NULL; a=ldap_next_attribute(ld, e, ptr ))
                   {
                           printf( "\tattribute: %s\n", a );

                           /* print each value */
                           if((vals = ldap_get_values( ld, e, a ))!=NULL)
                           {
                               for ( i = 0; vals[i] != NULL; i++ ) 
                                      printf( "\t\tvalue: %s\n", vals[i] );
                               
			ldap_value_free( vals );	
                                
		     }
						   
                           //ldap_memfree( a );//when i free here ,it cause dump
						   
                   }
                   if ( ptr != NULL ) {
                           ber_free( ptr, 0 );
			       }
                  ldap_memfree( a );//when i free here ,when it first  is execeted it     cause dump, following execting don't cause dump
           }
           /* free the search results */



So i don't know how to resove the problem 
someone can help me?
thank you
		  
          ldap_msgfree( res );


欢迎使用263天下邮免费信箱 http://freemail.x263.net
welcome to enjoy 263 Freemail http://freemail.x263.net
_____________________________________________________
		263在线_中国人的网上家园
Tel:010-64240315 Fax:010-64240295 ?1998-2001版权所有
263服务热线   010-64262631  263@263.net.cn  





欢迎使用263天下邮免费信箱 http://freemail.x263.net
welcome to enjoy 263 Freemail http://freemail.x263.net
_____________________________________________________
		263在线_中国人的网上家园
Tel:010-64240315 Fax:010-64240295 ?1998-2001版权所有
263服务热线   010-64262631  263@263.net.cn