Fix for locking issues in redmine/6334

FWIW, would have been nice to make a stack of CfLocks, but CfLock mallocs each string.