diff --git a/src/libusb/serialInterface.cxx b/src/libusb/serialInterface.cxx index 8b0c1be..fe954d5 100644 --- a/src/libusb/serialInterface.cxx +++ b/src/libusb/serialInterface.cxx @@ -210,10 +210,8 @@ std::string serialInterface_t::readPacket() const throw bmpCommsError_t{}; // Figure out how long that is (minus the beginning '&' and ending '#') const auto length{std::strlen(packet.data() + 1U) - 1U}; - // Make a new std::string of an appropriate length - std::string result(length + 1U, '\0'); - // And copy the result string in, returning it - std::memcpy(result.data(), packet.data() + 1U, length); + // Make a new std::string of an appropriate length, copying the data in to return it + std::string result{packet.data() + 1U, length}; console.debug("Remote read: "sv, result); return result; }