From 2aa11f6b16e844de7b0452d8b98efedfcd549b69 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Wed, 25 Nov 2026 08:57:02 +0800 Subject: [PATCH v1 1/2] Advance outbuf after copying leftover data in copy_read_data() If the leftover bytes fall short of minread, the next memcpy() would overwrite them. Advance outbuf by the number of bytes copied so the next read appends data at the correct offset. The current caller always passes 1 for minread, so any leftover byte satisfies the request and the bug is latent. Author: Chao Li --- src/backend/replication/logical/tablesync.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 1e17d220cd8..77917c89133 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -658,6 +658,7 @@ copy_read_data(void *outbuf, int minread, int maxread) if (avail > maxread) avail = maxread; memcpy(outbuf, ©buf.data[copybuf.cursor], avail); + outbuf = (char *) outbuf + avail; copybuf.cursor += avail; maxread -= avail; bytesread += avail; -- 2.50.1 (Apple Git-155)