From bc6616aaedbe4bcd2441334a3bf8f43fe9635bf1 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 2 Aug 2011 10:47:17 +0300 Subject: [PATCH] Avoid integer overflow when LIMIT + OFFSET >= 2^63. This fixes bug #6139 reported by Hitoshi Harada. --- src/backend/executor/nodeLimit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index 85d1a6e27f..f2d356d1f1 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -127,7 +127,7 @@ ExecLimit(LimitState *node) * the state machine state to record having done so. */ if (!node->noCount && - node->position >= node->offset + node->count) + node->position - node->offset >= node->count) { node->lstate = LIMIT_WINDOWEND; return NULL; -- 2.40.0