From 903a9fbf0cea31f374a42b1504a720a3a77cbdde Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 26 Nov 2020 12:32:46 +0100 Subject: [PATCH] math: Don't match longer function names The comparison here is a bit naive, so "n" matches "ncr", so technically math 'n(2, 3)' is equivalent to math 'ncr(2, 3)' Work towards #7508. --- src/tinyexpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index d48968fce..0cca4d689 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -222,7 +222,7 @@ static const te_builtin *find_builtin(const char *name, int len) { return std::strncmp(lhs.name, rhs, len) < 0; }); // We need to compare again because we might have gotten the first "larger" element. - if (found != end && std::strncmp(found->name, name, len) == 0) return found; + if (found != end && std::strncmp(found->name, name, len) == 0 && found->name[len] == 0) return found; return nullptr; }