pcm: fix stack allocation inside a loop