fix double free in shortcut operators 18/19518/2
Antoine ELIAS [Fri, 27 Oct 2017 14:21:10 +0000 (16:21 +0200)]
if []|[] then
end

if 1&[] then
end

to check :

SCILAB_VALGRIND_OPT="--tool=memcheck --leak-check=yes" ./bin/scilab-cli -profiling -quit -e "if []|[] then,end" 2> profil.out

SCILAB_VALGRIND_OPT="--tool=memcheck --leak-check=yes" ./bin/scilab-cli -profiling -quit -e "if 1&[] then, end" 2> profil.out

Change-Id: Ie4d1314961ade88d11d7772d4bd1d1b7a5375b89

scilab/modules/ast/src/cpp/ast/run_OpExp.hpp

index 8d6674b..4bdd6f9 100644 (file)
@@ -294,7 +294,11 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
                 if (pResult && e.getOper() == LogicalOpExp::logicalShortCutAnd)
                 {
                     types::InternalType* pResult2 = GenericShortcutAnd(pResult);
-                    pResult->killMe();
+                    if(pResult != pITL && pResult != pITR)
+                    {
+                        pResult->killMe();
+                    }
+
                     if (pResult2)
                     {
                         pResult = pResult2;
@@ -341,7 +345,11 @@ void RunVisitorT<T>::visitprivate(const LogicalOpExp &e)
                 if (pResult && e.getOper() == LogicalOpExp::logicalShortCutOr)
                 {
                     types::InternalType* pResult2 = GenericShortcutOr(pResult);
-                    pResult->killMe();
+                    if(pResult != pITL && pResult != pITR)
+                    {
+                        pResult->killMe();
+                    }
+
                     if (pResult2)
                     {
                         pResult = pResult2;