pipes: fixed memory leak in error path