Fix memory allocation mistake
authorPeter Eisentraut <[email protected]>
Wed, 6 Nov 2019 13:20:29 +0000 (14:20 +0100)
committerPeter Eisentraut <[email protected]>
Wed, 6 Nov 2019 13:22:50 +0000 (14:22 +0100)
The previous code was allocating more memory than necessary because
the formula used the wrong data type.

Reported-by: Jehan-Guillaume de Rorthais <[email protected]>
Discussion: https://www.postgresql.org/message-id/20191105172918.3e32a446@firost

src/backend/replication/logical/relation.c

index b849f1dc988c8e86d464c00a749192479b15f24d..54bcd16ec12ee45f90faac698b2229666e6785e1 100644 (file)
@@ -267,7 +267,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
         */
        desc = RelationGetDescr(entry->localrel);
        oldctx = MemoryContextSwitchTo(LogicalRepRelMapContext);
-       entry->attrmap = palloc(desc->natts * sizeof(int));
+       entry->attrmap = palloc(desc->natts * sizeof(AttrNumber));
        MemoryContextSwitchTo(oldctx);
 
        found = 0;