postgres.git / summary / log / commit / refs
commit 50cd651254354397ca2f2b795dd6aac300826076
Author: Tomas Vondra <tomas.vondra@postgresql.org>
Date: Fri Jan 24 23:36:48 2025 +0000
First released in: 18.0, 13.19, 14.16, 15.11, 16.7, 17.3
Use the correct sizeof() in BufFileLoadBuffer
The sizeof() call should reference buffer.data, because that's the
buffer we're reading data into, not the whole PGAlignedBuffer union.
This was introduced by 44cac93464, which replaced the simple buffer
with a PGAlignedBuffer field.
It's benign, because the buffer is the largest field of the union, so
the sizes are the same. But it's easy to trip over this in a patch, so
fix and backpatch. Commit 44cac93464 went into 12, but that's EOL.
Backpatch-through: 13
Discussion: https://postgr.es/m/928bdab1-6567-449f-98c4-339cd2203b87@vondra.me
src/backend/storage/file/buffile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/backend/storage/file/buffile.c b/src/backend/storage/file/buffile.c
index a263875fd5a..a44a34eeae1 100644
--- a/src/backend/storage/file/buffile.c
+++ b/src/backend/storage/file/buffile.c
@@ -459,7 +459,7 @@ BufFileLoadBuffer(BufFile *file)
*/
file->nbytes = FileRead(thisfile,
file->buffer.data,
- sizeof(file->buffer),
+ sizeof(file->buffer.data),
file->curOffset,
WAIT_EVENT_BUFFILE_READ);
if (file->nbytes < 0)
[parent: 24c5b73eb6ec]