From e5421e67724bc16f348d292cb694c76b787bb1c1 Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Sat, 17 Mar 2018 09:55:09 +0100 Subject: [PATCH] Adjust output/error for modulo zero operation Fixes https://github.com/sass/libsass/issues/2593 --- src/operators.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/operators.cpp b/src/operators.cpp index 65885bf196..02e303738c 100644 --- a/src/operators.cpp +++ b/src/operators.cpp @@ -127,15 +127,15 @@ namespace Sass { double lval = lhs.value(); double rval = rhs.value(); + if (op == Sass_OP::MOD && rval == 0) { + return SASS_MEMORY_NEW(String_Quoted, pstate, "NaN"); + } + if (op == Sass_OP::DIV && rval == 0) { std::string result(lval ? "Infinity" : "NaN"); return SASS_MEMORY_NEW(String_Quoted, pstate, result); } - if (op == Sass_OP::MOD && rval == 0) { - throw Exception::ZeroDivisionError(lhs, rhs); - } - size_t l_n_units = lhs.numerators.size(); size_t l_d_units = lhs.numerators.size(); size_t r_n_units = rhs.denominators.size();