Shouldn't av_mallocz be used here?