From 7ff0b0929f466a1701827a79704e3aa39f449f5c Mon Sep 17 00:00:00 2001 From: Antoine ELIAS Date: Tue, 24 Oct 2017 18:50:03 +0200 Subject: [PATCH] Operation with null operand crashs Scilab Change-Id: Iac7acc1cfd65fcb21754e106ddcf07df6872e214 --- scilab/CHANGES.md | 1 + scilab/modules/ast/src/cpp/ast/run_OpExp.hpp | 20 +++++++++++++++++++ .../modules/ast/tests/nonreg_tests/bug_15106.tst | 21 ++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 scilab/modules/ast/tests/nonreg_tests/bug_15106.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 4e02a35..20fa64f 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -440,6 +440,7 @@ the [development mailing list](dev@lists.scilab.org) for a particular toolbox. * [#15072](http://bugzilla.scilab.org/show_bug.cgi?id=15072): The context was stored as a root diagram attribute instead of being stored on each Superblock layer. * [#15079](http://bugzilla.scilab.org/show_bug.cgi?id=15079): When all children of a graphic handle have not the same number of sub-children, any vectorized extraction or insertion in subchildren failed. * [#15089](http://bugzilla.scilab.org/show_bug.cgi?id=15089): The `getcolor` GUI cleared and used the current figure. +* [#15106](http://bugzilla.scilab.org/show_bug.cgi?id=15106): Operation without operand crashed Scilab. * [#15107](http://bugzilla.scilab.org/show_bug.cgi?id=15107): Scilab failed to build with ocaml 4.04.0. * [#15117](http://bugzilla.scilab.org/show_bug.cgi?id=15117): Imbricated calls to `optim` / `leastsq` / `lsqrsolve` / `fsolve` either crashed or returned errors. * [#15119](http://bugzilla.scilab.org/show_bug.cgi?id=15119): Inequality comparisons between complex-encoded real numbers failed. diff --git a/scilab/modules/ast/src/cpp/ast/run_OpExp.hpp b/scilab/modules/ast/src/cpp/ast/run_OpExp.hpp index 4bdd6f9..c444177 100644 --- a/scilab/modules/ast/src/cpp/ast/run_OpExp.hpp +++ b/scilab/modules/ast/src/cpp/ast/run_OpExp.hpp @@ -33,7 +33,17 @@ void RunVisitorT::visitprivate(const OpExp &e) //os << ((Location)e.right_get().getLocation()).getLocationString() << std::endl; throw ast::InternalError(os.str(), 999, e.getRight().getLocation()); } + pITL = getResult(); + if (pITL == nullptr) + { + clearResult(); + std::wostringstream os; + wchar_t szError[bsiz]; + os_swprintf(szError, bsiz, _W("Operation '%ls': there is no left operand.\n").c_str(), e.getString().c_str()); + os << szError; + throw ast::InternalError(os.str(), 999, e.getLeft().getLocation()); + } /*getting what to assign*/ e.getRight().accept(*this); @@ -45,7 +55,17 @@ void RunVisitorT::visitprivate(const OpExp &e) //os << ((Location)e.right_get().getLocation()).getLocationString() << std::endl; throw ast::InternalError(os.str(), 999, e.getRight().getLocation()); } + pITR = getResult(); + if (pITR == nullptr) + { + clearResult(); + std::wostringstream os; + wchar_t szError[bsiz]; + os_swprintf(szError, bsiz, _W("Operation '%ls': there is no right operand.\n").c_str(), e.getString().c_str()); + os << szError; + throw ast::InternalError(os.str(), 999, e.getRight().getLocation()); + } if (pITL->getType() == types::InternalType::ScilabImplicitList) { diff --git a/scilab/modules/ast/tests/nonreg_tests/bug_15106.tst b/scilab/modules/ast/tests/nonreg_tests/bug_15106.tst new file mode 100644 index 0000000..daca3f2 --- /dev/null +++ b/scilab/modules/ast/tests/nonreg_tests/bug_15106.tst @@ -0,0 +1,21 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Antoine ELIAS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// <-- ENGLISH IMPOSED --> +// +// <-- Non-regression test for bug 15106 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/15106 +// +// <-- Short Description --> +// Operation with null operand crashs Scilab + + +assert_checkerror("whereami() == ""SCI""", sprintf(_("Operation ''%s'': there is no left operand."),"==")); +assert_checkerror("""SCI"" == whereami()", sprintf(_("Operation ''%s'': there is no right operand."),"==")); -- 1.7.9.5