Skip to content

Commit 3799d2e

Browse files
committed
Random should error if $limit is less than 1
1 parent a1cf611 commit 3799d2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,8 @@ namespace Sass {
10711071
BUILT_IN(random)
10721072
{
10731073
Number* l = dynamic_cast<Number*>(env["$limit"]);
1074-
if (l && trunc(l->value()) != l->value()) error("argument $limit of `" + string(sig) + "` must be an integer", pstate);
10751074
if (l) {
1075+
if (trunc(l->value()) != l->value() || l->value() == 0) error("argument $limit of `" + string(sig) + "` must be a positive integer", pstate);
10761076
uniform_real_distribution<> distributor(1, l->value() + 1);
10771077
uint_fast32_t distributed = static_cast<uint_fast32_t>(distributor(rand));
10781078
return new (ctx.mem) Number(pstate, (double)distributed);

0 commit comments

Comments
 (0)