double free patch by (Måns Rullgård <mru inprovide com>)