ItemId lp;
HeapTupleHeader htup;
- /* Some sanity checks */
- if (offnum < FirstOffsetNumber || offnum > maxoff)
+ /* Sanity check (pure paranoia) */
+ if (offnum < FirstOffsetNumber)
+ break;
+
+ /*
+ * An offset past the end of page's line pointer array is possible
+ * when the array was truncated
+ */
+ if (offnum > maxoff)
break;
lp = PageGetItemId(page, offnum);
bool tupdead,
recent_dead;
- /* Some sanity checks */
- if (offnum < FirstOffsetNumber || offnum > maxoff)
+ /* Sanity check (pure paranoia) */
+ if (offnum < FirstOffsetNumber)
+ break;
+
+ /*
+ * An offset past the end of page's line pointer array is possible
+ * when the array was truncated (original item must have been unused)
+ */
+ if (offnum > maxoff)
break;
/* If item is already processed, stop --- it must not be same chain */
*/
for (;;)
{
- /* Sanity check */
- if (nextoffnum < FirstOffsetNumber || nextoffnum > maxoff)
+ /* Sanity check (pure paranoia) */
+ if (offnum < FirstOffsetNumber)
+ break;
+
+ /*
+ * An offset past the end of page's line pointer array is possible
+ * when the array was truncated
+ */
+ if (offnum > maxoff)
break;
lp = PageGetItemId(page, nextoffnum);