postgres.git / summary / log / commit / refs

commit    308985b0b404a5891a1a629f38cc46c2b2dcb4be
Author:   Robert Haas <rhaas@postgresql.org>
Date:     Wed Sep 28 15:19:46 2016 +0000

    Fix dangling pointer problem in ReorderBufferSerializeChange.
    
    Commit 3fe3511d05127cc024b221040db2eeb352e7d716 introduced a new
    case into this function, but neglected to ensure that the "ondisk"
    pointer got updated after a possible reallocation as the code does
    in other cases.
    
    Stas Kelvich, per diagnosis by Konstantin Knizhnik.


src/backend/replication/logical/reorderbuffer.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 9b430b9acb5..e2a502c4431 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2250,6 +2250,9 @@ ReorderBufferSerializeChange(ReorderBuffer *rb, ReorderBufferTXN *txn, data = ((char *) rb->outbuf) + sizeof(ReorderBufferDiskChange); + /* might have been reallocated above */ + ondisk = (ReorderBufferDiskChange *) rb->outbuf; + /* write the prefix including the size */ memcpy(data, &prefix_size, sizeof(Size)); data += sizeof(Size); [parent: babe05bc2b78]