Fix bug #18982 with assertion violations when reverting buffers.