avcodec/sonic: check memory allocations