summaryrefslogtreecommitdiffstats
path: root/basic
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-07-10 12:09:37 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-07-10 16:51:57 +0200
commit2333dfd69c2933004834a572c981ca20a0537422 (patch)
tree402352147e633970973d929c0be6730249e79f7c /basic
parentprefer 8bit bitmap masks to 1bpp masks (diff)
downloadcore-2333dfd69c2933004834a572c981ca20a0537422.tar.gz
core-2333dfd69c2933004834a572c981ca20a0537422.zip
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>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/runtime.cxx3
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);
}
}