summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane MOTTELET <stephane.mottelet@utc.fr>2019-10-07 13:39:08 +0200
committerClément DAVID <clement.david@esi-group.com>2019-11-19 17:35:49 +0100
commit0fd9e8a7458c71da0f08536301ce05417a0e8e88 (patch)
treef53eaa13dabbb2ab7c6808cfb30bef3ac391760e
parent4b61afd394b5165c1d9e97f32839a64609274e3b (diff)
downloadscilab-0fd9e8a7458c71da0f08536301ce05417a0e8e88.zip
scilab-0fd9e8a7458c71da0f08536301ce05417a0e8e88.tar.gz
* Bug 16208 fixed: 3D string matrix may crash old C-api gateways
http://bugzilla.scilab.org/show_bug.cgi?id=16208 Change-Id: I5de8e746ce2f1976a9b2cb1f5a2bbe8e697ee4f0
-rw-r--r--scilab/CHANGES.md1
-rw-r--r--scilab/modules/api_scilab/src/cpp/api_stack_string.cpp2
-rw-r--r--scilab/modules/api_scilab/tests/nonreg_tests/bug_16208.tst22
3 files changed, 24 insertions, 1 deletions
diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md
index 1601275..d0a2679 100644
--- a/scilab/CHANGES.md
+++ b/scilab/CHANGES.md
@@ -185,5 +185,6 @@ Bug Fixes
185* [#16111](http://bugzilla.scilab.org/show_bug.cgi?id=16111): `isglobal` was not supporting non-scalar array of strings as input. 185* [#16111](http://bugzilla.scilab.org/show_bug.cgi?id=16111): `isglobal` was not supporting non-scalar array of strings as input.
186* [#16144](http://bugzilla.scilab.org/show_bug.cgi?id=16144): Addition of sparse matrices gave incorrect results. 186* [#16144](http://bugzilla.scilab.org/show_bug.cgi?id=16144): Addition of sparse matrices gave incorrect results.
187* [#16174](http://bugzilla.scilab.org/show_bug.cgi?id=16174): `libraryinfo` yielded 0x0 matrix of strings for libs without macro 187* [#16174](http://bugzilla.scilab.org/show_bug.cgi?id=16174): `libraryinfo` yielded 0x0 matrix of strings for libs without macro
188* [#16208](http://bugzilla.scilab.org/show_bug.cgi?id=16208): Using 3D string matrix with old C-api gateways may crash Scilab.
188 189
189 190
diff --git a/scilab/modules/api_scilab/src/cpp/api_stack_string.cpp b/scilab/modules/api_scilab/src/cpp/api_stack_string.cpp
index 941dfcb..0071997 100644
--- a/scilab/modules/api_scilab/src/cpp/api_stack_string.cpp
+++ b/scilab/modules/api_scilab/src/cpp/api_stack_string.cpp
@@ -87,7 +87,7 @@ SciErr getMatrixOfString(void* _pvCtx, int* _piAddress, int* _piRows, int* _piCo
87 types::String *pS = ((types::InternalType*)_piAddress)->getAs<types::String>(); 87 types::String *pS = ((types::InternalType*)_piAddress)->getAs<types::String>();
88 88
89 //non cummulative length 89 //non cummulative length
90 int iSize = pS->getSize(); 90 int iSize = (*_piRows)*(*_piCols);
91 if (_pstStrings == NULL || *_pstStrings == NULL) 91 if (_pstStrings == NULL || *_pstStrings == NULL)
92 { 92 {
93 for (int i = 0 ; i < iSize; i++) 93 for (int i = 0 ; i < iSize; i++)
diff --git a/scilab/modules/api_scilab/tests/nonreg_tests/bug_16208.tst b/scilab/modules/api_scilab/tests/nonreg_tests/bug_16208.tst
new file mode 100644
index 0000000..9f6e850
--- /dev/null
+++ b/scilab/modules/api_scilab/tests/nonreg_tests/bug_16208.tst
@@ -0,0 +1,22 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2019 - Stéphane MOTTELET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7//
8//
9// <-- CLI SHELL MODE -->
10// <-- NO CHECK REF -->
11//
12// <-- Non-regression test for bug 16208 -->
13//
14// <-- Bugzilla URL -->
15// http://bugzilla.scilab.org/16208
16//
17// <-- Short Description -->
18// Using 3D string matrix with old C-api gateways may crash Scilab
19
20x=string([1 2;3 4]);x(:,:,2)=x;
21assert_checkequal(gettext(x),x(:,:,1))
22