issue #19456: don't release an empty lock
Merge pull request #21 from shackbarth/19456b

issue #19456: don't release an empty lock