From 4fa5264b70c95183e3ed74d14ec0c7d370febd29 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20MOTTELET?= Date: Fri, 27 Sep 2019 10:45:30 +0200 Subject: [PATCH] * Bug 16200 fixed: concatenation of transposed cells crashed Scilab http://bugzilla.scilab.org/show_bug.cgi?id=16200 http://bugzilla.scilab.org/show_bug.cgi?id=14686 Change-Id: Ibde739acc4b29772e7eef74ab87b4b5fc091c766 --- scilab/CHANGES.md | 1 + scilab/modules/ast/src/cpp/types/cell.cpp | 11 ++++++++-- .../modules/ast/tests/nonreg_tests/bug_16200.tst | 21 ++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 scilab/modules/ast/tests/nonreg_tests/bug_16200.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index cf983c7..6db4727 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -234,6 +234,7 @@ Bug Fixes * [#16158](http://bugzilla.scilab.org/show_bug.cgi?id=16158): When a multicolumn array of rationals was displayed wide column per column, columns #2:$ were replaced with its column #2. * [#16164](http://bugzilla.scilab.org/show_bug.cgi?id=16164): Help pages in elementary_functions/signal_processing were mislocated. * [#16174](http://bugzilla.scilab.org/show_bug.cgi?id=16174): `libraryinfo` yielded 0x0 matrix of strings for libs without macro +* [#16200](http://bugzilla.scilab.org/show_bug.cgi?id=16200): Concatenation of transposed cells crashed Scilab. * [#16208](http://bugzilla.scilab.org/show_bug.cgi?id=16208): Using 3D string matrix with old C-api gateways may crash Scilab. * [#16209](http://bugzilla.scilab.org/show_bug.cgi?id=16209): grand() causes a freeze after several consecutive calls when using default base generator. * [#16210](http://bugzilla.scilab.org/show_bug.cgi?id=16210): The uicontrol.units = "normalized" property was not described. diff --git a/scilab/modules/ast/src/cpp/types/cell.cpp b/scilab/modules/ast/src/cpp/types/cell.cpp index 1a25052..b4a6b6c 100644 --- a/scilab/modules/ast/src/cpp/types/cell.cpp +++ b/scilab/modules/ast/src/cpp/types/cell.cpp @@ -155,8 +155,15 @@ bool Cell::transpose(InternalType *& out) int piDims[2] = {getCols(), getRows()}; pC->create(piDims, 2, &pIT, NULL); - Transposition::transpose_clone(getRows(), getCols(), m_pRealData, pC->m_pRealData); - + for (int i = 0, k = 0; i < getCols(); i++, k += getRows()) + { + for (int j = 0, l = 0; j < getRows(); j++, l += getCols()) + { + pC->m_pRealData[i + l] = m_pRealData[j + k]->clone(); + pC->m_pRealData[i + l]->IncreaseRef(); + } + } + return true; } diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_16200.tst b/scilab/modules/ast/tests/nonreg_tests/bug_16200.tst new file mode 100644 index 0000000..43f19a0 --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_16200.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2019 - Stéphane MOTTELET +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// +// <-- Non-regression test for bug 16200 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/16200 +// +// <-- Short Description --> +// Concatenation of transposed cells crashes Scilab + +c = {1,2} +assert_checkequal([c', c'],{1,1;2,2}) + -- 1.7.9.5