avpacket: Fix error checking in packet_alloc

Previously the wrong buffer pointer was checked, when buf
instead of *buf was checked. But checking the return value
instead is even better.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
