Fix for locking issues in redmine/6334

This may have been the `->previous` of another CfLockStack; you need to redirect that to point at your new stack.
```
CfLockStack **run = &LOCK_STACK;
while (*run)
{
    if (strcmp((*run)->lock, lock.lock) == 0 && ...)
    {
        CfLockStack *delete_me = run;
        *run = delete_me->previous;
        free(delete_me);
     }
     else
     {
        run = &((*run)->previous);
     }
}
```
will do this for you cleanly.  Alternatively, you can add a `CfLockStack *last = NULL;` before the loop, that you update to `last = stack;` when not deleting stack, just before advancing stack; then your deletion code says `if (last == NULL) { assert(delete_me == LOCK_STACK); LOCK_STACK = stack; } else { last->previous = stack; }`.  Some find this easier to read (because they find double dereference hard to grok).