make io::Cursor::push() safe to call with an empty ByteRange
Summary:
Clang's UndefinedBehaviorSanitizer flagged an issue that pushAtMost() could
call `memcpy(dest, nullptr, 0)` if the input was an empty `ByteRange`. A
default constructed `ByteRange` (or `StringPiece`) will be empty and both its
begin and end pointers will be null. Unfortunately it is undefined behavior to
call `memcpy()` with a null source pointer even if the length is 0.
This updates the `Cursor` and `Appender` code to avoid calling `memcpy()` at
all when the input length is 0.
Reviewed By: yfeldblum
Differential Revision:
D5322917
fbshipit-source-id:
67fce9579f97e7e93a5767b11cc5e43ff7be5876