Prevent overflow for block number in buffile.c

As coded, the start block calculated by BufFileAppend() would overflow
once more than 16k files are used with a default block size.  This issue
existed before b1e5c9fa9a, but there's no reason not to be clean about
it.

Per report from Coverity, with a fix suggested by Tom Lane.
This commit is contained in:
Michael Paquier 2023-11-20 09:14:53 +09:00
parent 28f84f72fb
commit 3650e7a393
1 changed files with 1 additions and 1 deletions

View File

@ -904,7 +904,7 @@ BufFileSize(BufFile *file)
int64
BufFileAppend(BufFile *target, BufFile *source)
{
int64 startBlock = target->numFiles * BUFFILE_SEG_SIZE;
int64 startBlock = (int64) target->numFiles * BUFFILE_SEG_SIZE;
int newNumFiles = target->numFiles + source->numFiles;
int i;