Be more wary about partially-valid LOCALLOCK data in RemoveLocalLock().

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 7e6e3bdd3c36d77b8a611dbf5e8c72164bc6108b
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2015-09-20T20:48:44Z
Releases: 9.3.10
Be more wary about partially-valid LOCALLOCK data in RemoveLocalLock().

RemoveLocalLock() must consider the possibility that LockAcquireExtended()
failed to palloc the initial space for a locallock's lockOwners array.
I had evidently meant to cope with this hazard when the code was originally
written (commit 1785acebf2ed14fd66955e2d9a55d77a025f418d), but missed that
the pfree needed to be protected with an if-test.  Just to make sure things
are left in a clean state, reset numLockOwners as well.

Per low-memory testing by Andreas Seltenreich.  Back-patch to all supported
branches.

Files

PathChange+/−
src/backend/storage/lmgr/lock.c modified +4 −2