avpacket: Fix error checking in packet_alloc