Fix memory leak around the exception wrapper.
Merge branch 'task/fix-memory-leak'