summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scilab/modules/ast/src/cpp/types/arrayof.cpp8
-rw-r--r--scilab/modules/ast/tests/nonreg_tests/bug_14808.dia.ref17
-rw-r--r--scilab/modules/ast/tests/nonreg_tests/bug_14808.tst18
3 files changed, 42 insertions, 1 deletions
diff --git a/scilab/modules/ast/src/cpp/types/arrayof.cpp b/scilab/modules/ast/src/cpp/types/arrayof.cpp
index 63d4bd0..ebe8e98 100644
--- a/scilab/modules/ast/src/cpp/types/arrayof.cpp
+++ b/scilab/modules/ast/src/cpp/types/arrayof.cpp
@@ -999,8 +999,14 @@ GenericType* ArrayOf<T>::extract(typed_list* _pArgs)
999 //index are ":" 999 //index are ":"
1000 bool isForceColVector = il.size() == 4; 1000 bool isForceColVector = il.size() == 4;
1001 1001
1002 if (start < 1 || end < 1)
1003 {
1004 return NULL;
1005 }
1006
1002 //std::cout << start << ":" << step << ":" << end << std::endl; 1007 //std::cout << start << ":" << step << ":" << end << std::endl;
1003 int size = static_cast<int>((end - start) / step + 1); 1008 int size = static_cast<int>((end - start) / step + 1);
1009
1004 if (size <= 0 || m_iSize == 0) 1010 if (size <= 0 || m_iSize == 0)
1005 { 1011 {
1006 return createEmpty(); 1012 return createEmpty();
@@ -1675,7 +1681,7 @@ bool ArrayOf<T>::invoke(typed_list & in, optional_list & /*opt*/, int /*_iRetCou
1675 if (!_out) 1681 if (!_out)
1676 { 1682 {
1677 std::wostringstream os; 1683 std::wostringstream os;
1678 os << _W("Invalid index.") << std::endl; 1684 os << _W("Invalid index.\n");
1679 throw ast::InternalError(os.str(), 999, e.getLocation()); 1685 throw ast::InternalError(os.str(), 999, e.getLocation());
1680 } 1686 }
1681 out.push_back(_out); 1687 out.push_back(_out);
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14808.dia.ref b/scilab/modules/ast/tests/nonreg_tests/bug_14808.dia.ref
new file mode 100644
index 0000000..5705661
--- /dev/null
+++ b/scilab/modules/ast/tests/nonreg_tests/bug_14808.dia.ref
@@ -0,0 +1,17 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Cedric Delamarre
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- CLI SHELL MODE -->
8//
9// <-- Non-regression test for bug 14808 -->
10//
11// <-- Bugzilla URL -->
12// http://bugzilla.scilab.org/14808
13//
14// <-- Short Description -->
15// E=[ 'A' 'B' 'C' 'D' 'E'] , E(0:0) Crash Scilab Console
16refMsg = msprintf(_("Invalid index.\n"));
17assert_checkerror("E=[ ""A"" ""B"" ""C"" ""D"" ""E""];E(0:0)", refMsg);
diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_14808.tst b/scilab/modules/ast/tests/nonreg_tests/bug_14808.tst
new file mode 100644
index 0000000..636f81f
--- /dev/null
+++ b/scilab/modules/ast/tests/nonreg_tests/bug_14808.tst
@@ -0,0 +1,18 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Cedric Delamarre
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- CLI SHELL MODE -->
8//
9// <-- Non-regression test for bug 14808 -->
10//
11// <-- Bugzilla URL -->
12// http://bugzilla.scilab.org/14808
13//
14// <-- Short Description -->
15// E=[ 'A' 'B' 'C' 'D' 'E'] , E(0:0) Crash Scilab Console
16
17refMsg = msprintf(_("Invalid index.\n"));
18assert_checkerror("E=[ ""A"" ""B"" ""C"" ""D"" ""E""];E(0:0)", refMsg);