diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-01-22 14:15:24 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2018-01-26 19:44:51 +0000 |
commit | f624e9c26f91def6b54f3a72f5bb36fa490b1aae (patch) | |
tree | 213519f07f26493aecb5f66023b7d9c572099ff3 /src/qml/jsruntime/qv4stringobject.cpp | |
parent | f5ee71993b3af8cf9cd89c605ab4bf30df30cb92 (diff) | |
download | qtdeclarative-f624e9c26f91def6b54f3a72f5bb36fa490b1aae.tar.gz |
Fix a couple of places where we'd free used objects
Make sure all our JS objects are referenced from the JS
stack before calling into the memory manager.
Change-Id: I88d622d37b9d6cfc19db4045ebd3fadc5bb4cabe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 4cc4a5c0cb..8125aa53b2 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -658,12 +658,13 @@ ReturnedValue StringPrototype::method_search(const FunctionObject *b, const Valu ReturnedValue StringPrototype::method_slice(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) { ExecutionEngine *v4 = b->engine(); - Heap::String *s = thisAsString(v4, thisObject); + Scope scope(v4); + ScopedString s(scope, thisAsString(v4, thisObject)); if (v4->hasException) return QV4::Encode::undefined(); Q_ASSERT(s); - const double length = s->length(); + const double length = s->d()->length(); double start = argc ? argv[0].toInteger() : 0; double end = (argc < 2 || argv[1].isUndefined()) @@ -683,7 +684,7 @@ ReturnedValue StringPrototype::method_slice(const FunctionObject *b, const Value const int intEnd = int(end); int count = qMax(0, intEnd - intStart); - return Encode(v4->memoryManager->alloc<ComplexString>(s, intStart, count)); + return Encode(v4->memoryManager->alloc<ComplexString>(s->d(), intStart, count)); } ReturnedValue StringPrototype::method_split(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) |