diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-10 12:09:37 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-07-10 16:51:57 +0200 |
commit | 2333dfd69c2933004834a572c981ca20a0537422 (patch) | |
tree | 402352147e633970973d929c0be6730249e79f7c | |
parent | df9f0e3cc57fb69ee38918b25ed91d97d1972685 (diff) |
tdf#134692: copy deep when there are multiple references to the old array
E.g., when we redim a copy of an array, the other copy would still have
its old dimensions, so shallow copy would share some array elements
between the now different arrays.
The other possible approach would be to try to modify the original array
to have the ByRef semantics.
Change-Id: Iab272ecbf4ade67048d6a126f17322441c5aa808
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98481
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | basic/source/runtime/runtime.cxx | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 9424482da487..0c9a17369729 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -2201,6 +2201,9 @@ static void implCopyDimArray( SbxDimArray* pNewArray, SbxDimArray* pOldArray, sa else { SbxVariable* pSource = pOldArray->Get32( pActualIndices ); + if (pSource && pOldArray->GetRefCount() > 1) + // tdf#134692: old array will stay alive after the redim - we need to copy deep + pSource = new SbxVariable(*pSource); pNewArray->Put32(pSource, pActualIndices); } } |