Fix memory leak in sample