1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

Fix datatype confusion in logtape.c's right_offset().

This could only matter if (a) long is wider than int, and (b) the heap
of free blocks exceeds UINT_MAX entries, which seems pretty unlikely.
Still, it's a theoretical bug, so backpatch to v13 where the typo came
in (in commit c02fdc922).

In passing, also make swap_nodes() use consistent datatypes.

Ma Liangzhu

Discussion: https://postgr.es/m/17336-fc4e522d26a750fd@postgresql.org
This commit is contained in:
Tom Lane 2021-12-14 11:46:36 -05:00
parent 4be3e005e5
commit 25c7faa1fe

View File

@ -345,7 +345,7 @@ ltsReadFillBuffer(LogicalTapeSet *lts, LogicalTape *lt)
static inline void static inline void
swap_nodes(long *heap, unsigned long a, unsigned long b) swap_nodes(long *heap, unsigned long a, unsigned long b)
{ {
unsigned long swap; long swap;
swap = heap[a]; swap = heap[a];
heap[a] = heap[b]; heap[a] = heap[b];
@ -359,7 +359,7 @@ left_offset(unsigned long i)
} }
static inline unsigned long static inline unsigned long
right_offset(unsigned i) right_offset(unsigned long i)
{ {
return 2 * i + 2; return 2 * i + 2;
} }