Avoid dereferencing null pointers by adding some checks to ByteVector.