From: Ondřej Kuzník Date: Fri, 8 Jun 2018 11:51:35 +0000 (+0100) Subject: ITS#8864 Fix ber_realloc after a partial ber_flush X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fb49d486a35fd4b2e993398c1eea0c8f7bc6ac40;p=openldap ITS#8864 Fix ber_realloc after a partial ber_flush --- diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c index e44a46c3b1..8477794022 100644 --- a/libraries/liblber/io.c +++ b/libraries/liblber/io.c @@ -128,7 +128,7 @@ ber_write( int ber_realloc( BerElement *ber, ber_len_t len ) { - ber_len_t total, offset, sos_offset; + ber_len_t total, offset, sos_offset, rw_offset; char *buf; assert( ber != NULL ); @@ -165,6 +165,7 @@ ber_realloc( BerElement *ber, ber_len_t len ) offset = ber->ber_ptr - buf; sos_offset = ber->ber_sos_ptr ? ber->ber_sos_ptr - buf : 0; /* if ber_sos_ptr != NULL, it is > ber_buf so that sos_offset > 0 */ + rw_offset = ber->ber_rwptr ? ber->ber_rwptr - buf : 0; buf = (char *) ber_memrealloc_x( buf, total, ber->ber_memctx ); if ( buf == NULL ) { @@ -176,6 +177,8 @@ ber_realloc( BerElement *ber, ber_len_t len ) ber->ber_ptr = buf + offset; if ( sos_offset ) ber->ber_sos_ptr = buf + sos_offset; + if ( ber->ber_rwptr ) + ber->ber_rwptr = buf + rw_offset; return( 0 ); }