]> git.lyx.org Git - lyx.git/commitdiff
Limit the amount of derivatives in external CAS
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 28 Mar 2017 09:17:35 +0000 (11:17 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 28 Mar 2017 09:17:35 +0000 (11:17 +0200)
The (arbitrary) limit is 1000.

Pointed out by coverity. A bad value could lock LyX.

src/mathed/MathExtern.cpp

index ee2004b5088644679fe6dee20eb44f6197f4cef6..da43bd4e3508043ee7bc6a70801efc90598d470b 100644 (file)
@@ -896,6 +896,10 @@ void extractDiff(MathData & ar)
                                int mult = 1;
                                if (extractNumber(script->up(), mult)) {
                                        //lyxerr << "mult: " << mult << endl;
+                                       if (mult > 1000) {
+                                               lyxerr << "Cannot differentiate more than 1000 times !" << endl;
+                                               continue;
+                                       }
                                        for (int i = 0; i < mult; ++i)
                                                diff->addDer(MathData(buf, dt + 1, st));
                                }