fixed potential memory leak in csv export