hevc: add missing malloc checks and free