Fix memory leaks in AC3 encoder
Fix serious out of bounds array write

Double errors had hidden the symptoms.