]> git.sur5r.net Git - openldap/commitdiff
address ITS#3914
authorPierangelo Masarati <ando@openldap.org>
Tue, 2 Aug 2005 23:22:10 +0000 (23:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 2 Aug 2005 23:22:10 +0000 (23:22 +0000)
servers/slapd/compare.c
servers/slapd/overlays/rwm.c

index 8787ee45c1711bced62a08573b9897411f79ccb6..e7cc311f2745ae7b84c67fe65205e0a7ee53b9cd 100644 (file)
@@ -120,7 +120,7 @@ do_compare(
 cleanup:;
        op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
        op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-       if ( ava.aa_value.bv_val ) {
+       if ( !BER_BVISNULL( &ava.aa_value ) ) {
                op->o_tmpfree( ava.aa_value.bv_val, op->o_tmpmemctx );
        }
 
index 20a754fa7c5875ede0d2fe6649c0cdc9772b3326..0e245a367d02129fab03674c86a6698d9827f74d 100644 (file)
@@ -111,11 +111,8 @@ rwm_op_add( Operation *op, SlapReply *rs )
        }
 
        if ( olddn != op->o_req_dn.bv_val ) {
-               ch_free( op->ora_e->e_name.bv_val );
-               ch_free( op->ora_e->e_nname.bv_val );
-
-               ber_dupbv( &op->ora_e->e_name, &op->o_req_dn );
-               ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn );
+               ber_bvreplace( &op->ora_e->e_name, &op->o_req_dn );
+               ber_bvreplace( &op->ora_e->e_nname, &op->o_req_ndn );
        }
 
        /* Count number of attributes in entry */ 
@@ -325,8 +322,7 @@ rwm_op_compare( Operation *op, SlapReply *rs )
                        return -1;
 
                } else if ( mapped_vals[0].bv_val != op->orc_ava->aa_value.bv_val ) {
-                       free( op->orc_ava->aa_value.bv_val );
-                       op->orc_ava->aa_value = mapped_vals[0];
+                       ber_bvreplace_x( &op->orc_ava->aa_value, &mapped_vals[0], op->o_tmpmemctx );
                }
                mapped_at = op->orc_ava->aa_desc->ad_cname;
 
@@ -371,7 +367,10 @@ rwm_op_compare( Operation *op, SlapReply *rs )
                                return -1;
                        }
 
-                       op->orc_ava->aa_value = mapped_vals[0];
+                       if ( mapped_vals[ 0 ].bv_val != op->orc_ava->aa_value.bv_val ) {
+                               ber_bvreplace_x( &op->orc_ava->aa_value, &mapped_vals[0],
+                                               op->o_tmpmemctx );
+                       }
                }
                op->orc_ava->aa_desc = ad;
        }
@@ -932,8 +931,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
                                         * the value is replaced by
                                         * ch_alloc'ed memory
                                         */
-                                       ch_free( bv[0].bv_val );
-                                       ber_dupbv( &bv[0], &mapped );
+                                       ber_bvreplace( &bv[0], &mapped );
                                }
                        }