]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/test.c
Cast char* argument to hh_to_c() to Byte*
[openldap] / libraries / libldap / test.c
index 7e3770f53826bf72be15fe360dd4fe62cb605490..23088a116620cb41626733ebcf55085a7bc48a1b 100644 (file)
@@ -83,7 +83,7 @@ get_list( char *prompt )
                        result = (char **) realloc( result,
                            sizeof(char *) * (num + 1) );
 
-               result[num++] = (char *) ldap_strdup( buf );
+               result[num++] = (char *) strdup( buf );
        }
        if ( result == (char **) 0 )
                return( NULL );
@@ -177,7 +177,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
                getline( buf, sizeof(buf), stdin, prompt2 );
                if ( buf[0] == '\0' )
                        break;
-               tmp.mod_type = ldap_strdup( buf );
+               tmp.mod_type = strdup( buf );
 
                tmp.mod_values = get_list( prompt3 );
 
@@ -323,12 +323,12 @@ main( int argc, char **argv )
                        break;
 
                case 't':       /* copy ber's to given file */
-                       copyfname = ldap_strdup( optarg );
+                       copyfname = strdup( optarg );
                        copyoptions = LBER_TO_FILE;
                        break;
 
                case 'T':       /* only output ber's to given file */
-                       copyfname = ldap_strdup( optarg );
+                       copyfname = strdup( optarg );
                        copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
                        break;
 
@@ -914,14 +914,14 @@ print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
 static void
 print_search_entry( LDAP *ld, LDAPMessage *res )
 {
-       BerElement      *ber;
-       char            *a, *dn, *ufn;
-       struct berval   **vals;
-       int             i;
        LDAPMessage     *e;
 
        for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
-           e = ldap_next_entry( ld, e ) ) {
+           e = ldap_next_entry( ld, e ) )
+       {
+               BerElement      *ber = NULL;
+               char *a, *dn, *ufn;
+
                if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
                        break;
 
@@ -935,12 +935,16 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
                free( ufn );
 
                for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
-                   a = ldap_next_attribute( ld, e, ber ) ) {
+                   a = ldap_next_attribute( ld, e, ber ) )
+               {
+                       struct berval   **vals;
+
                        printf( "\t\tATTR: %s\n", a );
                        if ( (vals = ldap_get_values_len( ld, e, a ))
                            == NULL ) {
                                printf( "\t\t\t(no values)\n" );
                        } else {
+                               int i;
                                for ( i = 0; vals[i] != NULL; i++ ) {
                                        int     j, nonascii;
 
@@ -965,6 +969,10 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
                                ber_bvecfree( vals );
                        }
                }
+
+               if(ber != NULL) {
+                       ber_free( ber, 0 );
+               }
        }
 
        if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT