From dc9ef985efc777e393d03a94dfe59b1b7bdfee9e Mon Sep 17 00:00:00 2001 From: Cedric Delamarre Date: Fri, 29 May 2015 11:10:48 +0200 Subject: [PATCH] struct clone fixed. * A struct cloned must have all SingleStruct reference set to 1 because we cant increase reference of SingleStruct when we do it on a Struct. z.y = 42; y.o = z; // here z is cloned, after extraction of z(1), two Struct // contain the same SingleStruct with ref = 1 because of extraction without copy. // When the temporary Struct "z(1)" is deleted, the SingleStruct is deleted too. z(1).x=12; Change-Id: I3b90752cdae7cdfe172bed30d8ad67959dc787f6 --- scilab/modules/ast/src/cpp/types/struct.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scilab/modules/ast/src/cpp/types/struct.cpp b/scilab/modules/ast/src/cpp/types/struct.cpp index 14de9c8..3fde4f6 100644 --- a/scilab/modules/ast/src/cpp/types/struct.cpp +++ b/scilab/modules/ast/src/cpp/types/struct.cpp @@ -93,12 +93,8 @@ Struct::Struct(Struct *_oStructCopyMe) create(_oStructCopyMe->getDimsArray(), _oStructCopyMe->getDims(), &pIT, NULL); for (int i = 0 ; i < getSize() ; i++) { - m_pRealData[i] = NULL; - } - - for (int i = 0 ; i < getSize() ; i++) - { pIT[i] = _oStructCopyMe->get(i)->clone(); + pIT[i]->IncreaseRef(); } #ifndef NDEBUG Inspector::addItem(this); -- 1.7.9.5