[Issue 10350] Free ch_calloc-allocated memory in error paths