Bug 836519 - Check if cursor references exist before releasing them. r=gwagner