Poor man's RAII for dump and patch