aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-27 09:29:51 +0000
committersaturneric <[email protected]>2024-07-27 09:29:51 +0000
commit469eb2b4e00035939ab2621223321eef9dd0252e (patch)
treed8b1653a72dab40f1c99a198939c1f1b0e21bc87 /include
parentfeat: remove dependency 'spdlog' (diff)
downloadModules-469eb2b4e00035939ab2621223321eef9dd0252e.tar.gz
Modules-469eb2b4e00035939ab2621223321eef9dd0252e.zip
fix: solve a memory leak issue
Diffstat (limited to 'include')
-rw-r--r--include/GFModuleCommonUtils.hpp11
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]));