avcodec/sonic: fix memleaks