diff options
author | saturneric <[email protected]> | 2024-07-27 09:29:51 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-07-27 09:29:51 +0000 |
commit | 469eb2b4e00035939ab2621223321eef9dd0252e (patch) | |
tree | d8b1653a72dab40f1c99a198939c1f1b0e21bc87 /include | |
parent | feat: remove dependency 'spdlog' (diff) | |
download | Modules-469eb2b4e00035939ab2621223321eef9dd0252e.tar.gz Modules-469eb2b4e00035939ab2621223321eef9dd0252e.zip |
fix: solve a memory leak issue
Diffstat (limited to 'include')
-rw-r--r-- | include/GFModuleCommonUtils.hpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/include/GFModuleCommonUtils.hpp b/include/GFModuleCommonUtils.hpp index a300ddc..392aaef 100644 --- a/include/GFModuleCommonUtils.hpp +++ b/include/GFModuleCommonUtils.hpp @@ -97,11 +97,8 @@ inline auto QMapToGFModuleMetaDataList(const QMap<QString, QString>& map) QByteArray const key = it.key().toUtf8(); QByteArray const value = it.value().toUtf8(); - new_node->key = new char[key.size() + 1]; - std::strcpy(const_cast<char*>(new_node->key), key.constData()); - - new_node->value = new char[value.size() + 1]; - std::strcpy(const_cast<char*>(new_node->value), value.constData()); + new_node->key = DUP(key); + new_node->value = DUP(value); new_node->next = nullptr; @@ -139,8 +136,8 @@ auto SecureCreateSharedObject(Args&&... args) -> std::shared_ptr<T> { } } -inline auto CharArrayToQStringList(char** pl_components, int size) - -> QStringList { +inline auto CharArrayToQStringList(char** pl_components, + int size) -> QStringList { QStringList list; for (int i = 0; i < size; ++i) { list.append(QString::fromUtf8(pl_components[i])); |