fix buffer locking