[Issue 10348] New: Free ch_malloc-allocated memory in error paths