api: Handle NULs and newlines in buffer_*_line.
FIXUP: simpler null test