]> git.sur5r.net Git - openldap/commitdiff
Never let ldif_parse_line() return a NULL value with success.
authorHallvard Furuseth <hallvard@openldap.org>
Mon, 2 Dec 2002 22:46:07 +0000 (22:46 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Mon, 2 Dec 2002 22:46:07 +0000 (22:46 +0000)
clients/tools/ldapmodify.c
libraries/libldif/line64.c
servers/slapd/entry.c
servers/slurpd/re.c

index a131d4cab24153050df0b49b006c75b93cf4160f..00c1899905d26036c785120e3dda02e51e027356 100644 (file)
@@ -976,12 +976,12 @@ process_ldif_rec( char *rbuf, int count )
                {
                        if( val.bv_len == 0 || atoi(val.bv_val) != 1 ) {
                        fprintf( stderr, "%s: invalid version %s, line %d (ignored)\n",
-                               prog, val.bv_val == NULL ? "(null)" : val.bv_val, linenum );
+                               prog, val.bv_val, linenum );
                        }
                        version++;
 
            } else if ( strcasecmp( type, T_DN_STR ) == 0 ) {
-               if (( dn = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
+               if (( dn = ber_strdup( val.bv_val )) == NULL ) {
                    perror( "strdup" );
                    exit( EXIT_FAILURE );
                }
@@ -1097,7 +1097,7 @@ process_ldif_rec( char *rbuf, int count )
 
        if ( expect_newrdn ) {
            if ( strcasecmp( type, T_NEWRDNSTR ) == 0 ) {
-                       if (( newrdn = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
+                       if (( newrdn = ber_strdup( val.bv_val )) == NULL ) {
                    perror( "strdup" );
                    exit( EXIT_FAILURE );
                }
@@ -1121,7 +1121,7 @@ process_ldif_rec( char *rbuf, int count )
            }
        } else if ( expect_newsup ) {
            if ( strcasecmp( type, T_NEWSUPSTR ) == 0 ) {
-               if (( newsup = ber_strdup( val.bv_val ? val.bv_val : "" )) == NULL ) {
+               if (( newsup = ber_strdup( val.bv_val )) == NULL ) {
                    perror( "strdup" );
                    exit( EXIT_FAILURE );
                }
@@ -1137,7 +1137,7 @@ process_ldif_rec( char *rbuf, int count )
                    prog, linenum, dn );
            rc = LDAP_PARAM_ERROR;
        } else {
-               addmodifyop( &pmods, modop, type, val.bv_val == NULL ? NULL : &val );
+               addmodifyop( &pmods, modop, type, &val );
        }
 
 end_line:
index 94c3f9dd4b46e7d5ff5daa38ebea1a898e61c945..1d0310793b98a030a41aa0b47b7695d0c7af1f56 100644 (file)
@@ -143,9 +143,8 @@ ldif_parse_line(
                        /* no value is present, error out */
                        ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
                                "ldif_parse_line: %s missing base64 value\n", type );
-                       value = NULL;
-                       vlen = 0;
-                       goto done;
+                       ber_memfree( freeme );
+                       return( -1 );
                }
 
                byte = value = s;
@@ -196,9 +195,8 @@ ldif_parse_line(
                        /* no value is present, error out */
                        ber_pvt_log_printf( LDAP_DEBUG_PARSE, ldif_debug,
                                "ldif_parse_line: %s missing URL value\n", type );
-                       value = NULL;
-                       vlen = 0;
-                       goto done;
+                       ber_memfree( freeme );
+                       return( -1 );
                }
 
                if( ldif_fetch_url( s, &value, &vlen ) ) {
@@ -214,7 +212,6 @@ ldif_parse_line(
                vlen = (int) (d - s);
        }
 
-done:
        type = ber_strdup( type );
 
        if( type == NULL ) {
@@ -225,7 +222,7 @@ done:
                return( -1 );
        }
 
-       if( !url && value != NULL ) {
+       if( !url ) {
                p = ber_memalloc( vlen + 1 );
                if( p == NULL ) {
                        ber_pvt_log_printf( LDAP_DEBUG_ANY, ldif_debug,
index 98f5842f8a45e66f9544ee3430d512900406c6dd..b07ad02b4327eb73e0aa5e43109e1757d5fc864b 100644 (file)
@@ -112,15 +112,13 @@ str2entry( char *s )
 #ifdef NEW_LOGGING
                                LDAP_LOG( OPERATION, DETAIL1, "str2entry: "
                                        "entry %ld has multiple DNs \"%s\" and \"%s\"\n",
-                                       (long) e->e_id, e->e_dn,
-                                       vals[0].bv_val != NULL ? vals[0].bv_val : ""  );
+                                       (long) e->e_id, e->e_dn, vals[0].bv_val );
 #else
                                Debug( LDAP_DEBUG_ANY, "str2entry: "
                                        "entry %ld has multiple DNs \"%s\" and \"%s\"\n",
-                                   (long) e->e_id, e->e_dn,
-                                       vals[0].bv_val != NULL ? vals[0].bv_val : "" );
+                                   (long) e->e_id, e->e_dn, vals[0].bv_val );
 #endif
-                               if( vals[0].bv_val != NULL ) free( vals[0].bv_val );
+                               free( vals[0].bv_val );
                                entry_free( e );
                                return NULL;
                        }
index dbde0bc43dbd947cdb62e61bd858f0b19e659e03..e0b38c65e31b184d81d07d05a376e7902ff0ebd4 100644 (file)
@@ -221,14 +221,12 @@ Re_parse(
                        type, 0, 0 );
 #endif
                free( type );
-               if ( value != NULL )
-                       free( value );
+               free( value );
                return -1;
            }
        }
        free( type );
-       if ( value != NULL )
-               free( value );
+       free( value );
     }
 
     if ( state != GOT_ALL ) {
@@ -367,8 +365,7 @@ get_repl_hosts(
        free( type );
        if ( !repl_ok ) {
            warn_unknown_replica( value, port );
-           if ( value != NULL )
-               free( value );
+           free( value );
            continue;
        }
 
@@ -387,8 +384,7 @@ get_repl_hosts(
        rh[ nreplicas ].rh_port = port;
        nreplicas++;
 
-       if ( value != NULL )
-               free( value );
+       free( value );
     }
 
     if ( nreplicas == 0 ) {