fix double free crash in encoder
Merge pull request #479 from volvet/fix-double-free-crash

fix double free crash in encoder