diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-02-20 10:36:37 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-02-20 10:39:39 +0100 |
commit | 78fd438f158839ffebcd52cc7974eac28489dbdd (patch) | |
tree | eb123d5ae22be0a0fed3a44940a71fa9653b3ef7 | |
parent | ea0956ccad5faab85f828279d500caedb07efac3 (diff) |
QV4Engine: Avoid memory leak in toVariant conversion
Change-Id: I2c713fd759ac40aaaac0c0943edb993d3e27686b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a900e710c2..aea81b1e07 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -1520,7 +1520,11 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int return retn; #endif if (typeHint != -1) { - retn = QVariant(typeHint, QMetaType::create(typeHint)); + // the QVariant constructor will create a copy, so we have manually + // destroy the value returned by QMetaType::create + auto temp = QMetaType::create(typeHint); + retn = QVariant(typeHint, temp); + QMetaType::destroy(typeHint, temp); auto retnAsIterable = retn.value<QtMetaTypePrivate::QSequentialIterableImpl>(); if (retnAsIterable._iteratorCapabilities & QtMetaTypePrivate::ContainerIsAppendable) { auto const length = a->getLength(); |