Changed to accept null and/or 0-length buffer.