From 173cd84481114f86c4e0ba84b1947b1d9240908e Mon Sep 17 00:00:00 2001 From: Adeline CARNIS Date: Thu, 27 Oct 2016 12:27:20 +0200 Subject: [PATCH] * Bug #14824 fixed - Incorrect error message with mfprintf(fd, '%d', []) Change-Id: Id650c3ba86a06546b868a7771715abc6f0ed3c46 --- scilab/CHANGES.md | 1 + .../fileio/sci_gateway/cpp/sci_mfprintf.cpp | 5 ++++ .../fileio/tests/nonreg_tests/bug_14824.dia.ref | 24 ++++++++++++++++++++ .../fileio/tests/nonreg_tests/bug_14824.tst | 23 +++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 scilab/modules/fileio/tests/nonreg_tests/bug_14824.dia.ref create mode 100644 scilab/modules/fileio/tests/nonreg_tests/bug_14824.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index ba1e968..1fa2180 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -414,6 +414,7 @@ Bug Fixes * [#14775](http://bugzilla.scilab.org/show_bug.cgi?id=14775): Loading empty (0 bytes) .sod File crashed scilab * [#14808](http://bugzilla.scilab.org/show_bug.cgi?id=14808): E=[ 'A' 'B' 'C' 'D' 'E'] , E(0:0) Crash Scilab Console * [#14821](http://bugzilla.scilab.org/show_bug.cgi?id=14821): `getio` function was missing. An error on the diary file opened has been corrected +* [#14824](http://bugzilla.scilab.org/show_bug.cgi?id=14824): Incorrect error message with `mfprintf(fd, "%d", [])`. * [#14839](http://bugzilla.scilab.org/show_bug.cgi?id=14839): `plot2d2` crashed Scilab. * [#14887](http://bugzilla.scilab.org/show_bug.cgi?id=14887): For many graphic handle types, the display of the `.tag` value missed `".."` delimiters * [#14909](http://bugzilla.scilab.org/show_bug.cgi?id=14909): getlongpathname and getshortpathname return values with "\" instead of "/" diff --git a/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp b/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp index e71a7c1..b373dca 100644 --- a/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp +++ b/scilab/modules/fileio/sci_gateway/cpp/sci_mfprintf.cpp @@ -148,6 +148,11 @@ types::Function::ReturnValue sci_mfprintf(types::typed_list &in, int _iRetCount, wcsInput = pFileStr->get(0); wcsStringToWrite = scilab_sprintf("mfprintf", wcsInput, in, &nbrOfLines, &iNewLine); + if (wcsStringToWrite == NULL) + { + return types::Function::Error; + } + if (isSTD) { for (int i = 0; i < nbrOfLines; i++) diff --git a/scilab/modules/fileio/tests/nonreg_tests/bug_14824.dia.ref b/scilab/modules/fileio/tests/nonreg_tests/bug_14824.dia.ref new file mode 100644 index 0000000..72b177a --- /dev/null +++ b/scilab/modules/fileio/tests/nonreg_tests/bug_14824.dia.ref @@ -0,0 +1,24 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2016 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 14824 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14824 +// +// <-- Short Description --> +// Incorrect error message with mfprintf(fd, "%d", []) +fd = mopen('tmp.tmp', 'w'); +str = "mfprintf(fd, ""%d"", [])"; +assert_checkfalse(execstr(str ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input arguments: data doesn''t fit with format.\n"), "mfprintf"); +assert_checkerror(str, refMsg); +mclose(fd) + ans = + 0. diff --git a/scilab/modules/fileio/tests/nonreg_tests/bug_14824.tst b/scilab/modules/fileio/tests/nonreg_tests/bug_14824.tst new file mode 100644 index 0000000..828d708 --- /dev/null +++ b/scilab/modules/fileio/tests/nonreg_tests/bug_14824.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2016 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// +// <-- Non-regression test for bug 14824 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14824 +// +// <-- Short Description --> +// Incorrect error message with mfprintf(fd, "%d", []) + +fd = mopen('tmp.tmp', 'w'); +str = "mfprintf(fd, ""%d"", [])"; +assert_checkfalse(execstr(str ,"errcatch") == 0); +refMsg = msprintf(_("%s: Wrong number of input arguments: data doesn''t fit with format.\n"), "mfprintf"); +assert_checkerror(str, refMsg); +mclose(fd) -- 1.7.9.5