From f7c8ef7f55b64b8d594d1675a7dc183222729bc1 Mon Sep 17 00:00:00 2001
From: Ranier Vilela <ranier.vf@gmail.com>
Date: Thu, 24 Aug 2023 14:02:42 -0300
Subject: [PATCH] Avoid possible overflow with ltsGetFreeBlock function

nFreeBlocks stores the number of free blocks and
your type is *long*.

At Function ltsGetFreeBlock is locally stored in
heapsize wich type is *int*

With Windows both *long* and *int* are 4 bytes.
But with Linux *long* is 8 bytes and *int* are 4 bytes.

Author: Ranier vilela (ranier.vf@gmail.com)
---
 src/backend/utils/sort/logtape.c | 2 +-
 1files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/backend/utils/sort/logtape.c b/src/backend/utils/sort/logtape.c
index 52b8898d5e..f31878bdee 100644
--- a/src/backend/utils/sort/logtape.c
+++ b/src/backend/utils/sort/logtape.c
@@ -372,7 +372,7 @@ ltsGetFreeBlock(LogicalTapeSet *lts)
 {
 	long	   *heap = lts->freeBlocks;
 	long		blocknum;
-	int			heapsize;
+	long		heapsize;
 	long		holeval;
 	unsigned long holepos;
 
-- 
2.32.0.windows.1

