From e67948823d6810c2de784859da52a261bf80b550 Mon Sep 17 00:00:00 2001 From: Lars Knoll <lars.knoll@digia.com> Date: Fri, 31 Oct 2014 10:40:14 +0100 Subject: [PATCH] Don't allocate less memory than required When switching from a simple to a sparse array, keep the previously allocated size, to not corrupt memory. Change-Id: I33f0fb049a2ad6f24ee3703f2c333855830fe9d2 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> --- src/qml/jsruntime/qv4arraydata.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 3235a116ee..12254c6384 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -104,6 +104,8 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt if (requested <= d->alloc() && newType == d->type() && hasAttrs == enforceAttributes) return; + if (alloc < d->alloc()) + alloc = d->alloc(); if (d->type() < Sparse) { offset = static_cast<SimpleArrayData *>(d)->d()->offset; -- GitLab