Fix use-after-free and read overrun when adding CAs
When adding a CA dynamically, take ownership of the record when we add
it to the main context. Also, allocate space for ownership of its own
events and get them started.
Reproducer provided by Jan Cholasta.