From: Robert Haas <rhaas@postgresql.org>
Date: Thu, 24 Jul 2014 12:19:19 +0000 (-0400)
Subject: Avoid access to already-released lock in LockRefindAndRelease.
X-Git-Tag: REL9_5_ALPHA1~1684
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32d78894c2a92cbb2fe7b9160936fee31672e7d9;p=postgresql

Avoid access to already-released lock in LockRefindAndRelease.

Spotted by Tom Lane.
---

diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index cd468bcc99..723051efb5 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -2949,7 +2949,7 @@ LockRefindAndRelease(LockMethod lockMethodTable, PGPROC *proc,
 	 * Decrement strong lock count.  This logic is needed only for 2PC.
 	 */
 	if (decrement_strong_lock_count
-		&& ConflictsWithRelationFastPath(&lock->tag, lockmode))
+		&& ConflictsWithRelationFastPath(locktag, lockmode))
 	{
 		uint32		fasthashcode = FastPathStrongLockHashPartition(hashcode);