avcodec/avpacket: Fix memory allocation failure check