diff --git a/contrib/pg_visibility/pg_visibility.c b/contrib/pg_visibility/pg_visibility.c
index db796e35cb..1c0a0fbdfb 100644
--- a/contrib/pg_visibility/pg_visibility.c
+++ b/contrib/pg_visibility/pg_visibility.c
@@ -760,9 +760,9 @@ collect_corrupt_items(Oid relid, bool all_visible, bool all_frozen)
 		 * the page lock.  Recheck to avoid returning spurious results.
 		 */
 		if (all_frozen && !VM_ALL_FROZEN(rel, blkno, &vmbuffer))
-			check_frozen = false;
+			check_frozen = true;
 		if (all_visible && !VM_ALL_VISIBLE(rel, blkno, &vmbuffer))
-			check_visible = false;
+			check_visible = true;
 		if (!check_visible && !check_frozen)
 		{
 			UnlockReleaseBuffer(buffer);
