You let it operate on a copy of the input data and check integrity afterwards. If it doesn't reach a valid state you discard it as failed/corrupted.
You can get lucky and sometimes avoid corruption, but eventually you're going to hit something important like leaving a libc heap allocator mutex locked when you kill a thread in the middle of an allocation.