]> git.sur5r.net Git - openldap/commitdiff
serialNumberAndIssuerPretty() and serialNumberAndIssuerNormalize()
authorHallvard Furuseth <hallvard@openldap.org>
Sat, 30 Jul 2005 23:30:42 +0000 (23:30 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Sat, 30 Jul 2005 23:30:42 +0000 (23:30 +0000)
were confused about realloced memory.

servers/slapd/schema_init.c

index 7b5d1ff435ba9b0dbbdf429a180a39afe1ec17de..6c7fb42a69cc608685327ffe0cb2159063a6c4c8 100644 (file)
@@ -2434,13 +2434,14 @@ serialNumberAndIssuerPretty(
        out->bv_len = sn.bv_len + newi.bv_len + 1;
        out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx );
 
-       if( BER_BVISNULL( out ) ) {
+       if( out->bv_val == NULL ) {
+               out->bv_len = 0;
                slap_sl_free( newi.bv_val, ctx );
                return LDAP_OTHER;
        }
 
        /* push issuer over */
-       AC_MEMCPY( &out->bv_val[sn.bv_len+1], newi.bv_val, newi.bv_len );
+       AC_MEMCPY( &out->bv_val[sn.bv_len+1], out->bv_val, newi.bv_len );
        /* insert sn and "$" */
        AC_MEMCPY( out->bv_val, sn.bv_val, sn.bv_len );
        out->bv_val[sn.bv_len] = '$';
@@ -2510,13 +2511,14 @@ serialNumberAndIssuerNormalize(
        out->bv_len = sn.bv_len + newi.bv_len + 1;
        out->bv_val = slap_sl_realloc( newi.bv_val, out->bv_len + 1, ctx );
 
-       if( BER_BVISNULL( out ) ) {
+       if( out->bv_val == NULL ) {
+               out->bv_len = 0;
                slap_sl_free( newi.bv_val, ctx );
                return LDAP_OTHER;
        }
 
        /* push issuer over */
-       AC_MEMCPY( &out->bv_val[sn.bv_len+1], newi.bv_val, newi.bv_len );
+       AC_MEMCPY( &out->bv_val[sn.bv_len+1], out->bv_val, newi.bv_len );
        /* insert sn and "$" */
        AC_MEMCPY( out->bv_val, sn.bv_val, sn.bv_len );
        out->bv_val[sn.bv_len] = '$';