From 948f1261239ff476a343b6bd61ffe0659cc0b3be Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 27 Jun 2019 23:46:55 -0400 Subject: [PATCH] fix: Error on empty min/max call Closes #2914 --- src/fn_numbers.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/fn_numbers.cpp b/src/fn_numbers.cpp index 8f4784af2a..e7c2039052 100644 --- a/src/fn_numbers.cpp +++ b/src/fn_numbers.cpp @@ -105,7 +105,11 @@ namespace Sass { { List* arglist = ARG("$numbers", List); Number_Obj least; - for (size_t i = 0, L = arglist->length(); i < L; ++i) { + size_t L = arglist->length(); + if (L == 0) { + error("At least one argument must be passed.", pstate, traces); + } + for (size_t i = 0; i < L; ++i) { Expression_Obj val = arglist->value_at_index(i); Number_Obj xi = Cast(val); if (!xi) { @@ -123,7 +127,11 @@ namespace Sass { { List* arglist = ARG("$numbers", List); Number_Obj greatest; - for (size_t i = 0, L = arglist->length(); i < L; ++i) { + size_t L = arglist->length(); + if (L == 0) { + error("At least one argument must be passed.", pstate, traces); + } + for (size_t i = 0; i < L; ++i) { Expression_Obj val = arglist->value_at_index(i); Number_Obj xi = Cast(val); if (!xi) {