From: Cedric Delamarre Date: Mon, 29 Feb 2016 10:33:25 +0000 (+0100) Subject: [bug_14433] atanh fixed about double free X-Git-Tag: 6.0.0-beta-2~300 X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=commitdiff_plain;h=7cc612e2321e9a617a8d6d967efd5d823c6bb08c [bug_14433] atanh fixed about double free test_run elementary_functions bug_14433 test_run elementary_functions bug_14433 mode_nwni_profiling Change-Id: I3420b67dd9c32e7cc731e208a6b072b1d581a094 --- diff --git a/scilab/CHANGES b/scilab/CHANGES index 60b53f3..61ac987 100644 --- a/scilab/CHANGES +++ b/scilab/CHANGES @@ -298,6 +298,8 @@ Known issues Bug Fixes ========= +* Bug #14433 fixed - acoth (which call atanh) crash scilab + In 6.0.0 beta-1: * Bug #6057 fixed - trailing space after minus sign has been removed from the display of values diff --git a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_atanh.cpp b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_atanh.cpp index 0d35e2c..c0e4e37 100644 --- a/scilab/modules/elementary_functions/sci_gateway/cpp/sci_atanh.cpp +++ b/scilab/modules/elementary_functions/sci_gateway/cpp/sci_atanh.cpp @@ -70,13 +70,13 @@ types::Function::ReturnValue sci_atanh(types::typed_list &in, int _iRetCount, ty double dAbsIn = abs(pInR[i]); if (dAbsIn == 1) { - if (pInI && pDblIn->isComplex() == false) - { - delete[] pInI; - } - if (ConfigVariable::getIeee() == 0) { + if (pInI && pDblIn->isComplex() == false) + { + delete[] pInI; + } + Scierror(78, _("%s: Warning: Wrong value for input argument #%d : Singularity of the function.\n"), "atanh", 1); return types::Function::Error; } @@ -113,6 +113,11 @@ types::Function::ReturnValue sci_atanh(types::typed_list &in, int _iRetCount, ty pOutR[i] = d.real(); pOutI[i] = d.imag(); } + + if (pInI && pDblIn->isComplex() == false) + { + delete[] pInI; + } } else { diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.dia.ref new file mode 100644 index 0000000..83ff127 --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.dia.ref @@ -0,0 +1,22 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Cedric Delamarre +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 14433 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14433 +// +// <-- Short Description --> +// acoth (which call atanh) crash scilab +// default ieee is 0 +x=-30:0.1:30; +x(abs(x)<=1)=%nan; +acoth(x); +ieee(2); +x=-30:0.1:30; +x(abs(x)<=1)=%nan; +acoth(x); diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.tst new file mode 100644 index 0000000..74382ae --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14433.tst @@ -0,0 +1,26 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Cedric Delamarre +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 14433 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=14433 +// +// <-- Short Description --> +// acoth (which call atanh) crash scilab + +// default ieee is 0 +x=-30:0.1:30; +x(abs(x)<=1)=%nan; +acoth(x); + +ieee(2); +x=-30:0.1:30; +x(abs(x)<=1)=%nan; +acoth(x);