From 1365c7d131329e898efbbb04b21cb91f5c64c745 Mon Sep 17 00:00:00 2001 From: Kevin Yang Date: Fri, 4 Dec 2020 11:13:03 +0800 Subject: [PATCH] Update Utils.cpp fixed issue: truncated data when \0 if in the array which is not the end --- src/Utils.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Utils.cpp b/src/Utils.cpp index 88b3dc8..0263884 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -421,9 +421,8 @@ std::string Utils::stringFromGVariantByteArray(const GVariant *pVariant) { gsize size; gconstpointer pPtr = g_variant_get_fixed_array(const_cast(pVariant), &size, 1); - std::vector array(size + 1, 0); - memcpy(array.data(), pPtr, size); - return array.data(); + std::string str((char*)pPtr, size); + return str; } }; // namespace ggk