diff --git a/src/expand.cpp b/src/expand.cpp index 54add191d7..eaeca6ccbe 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -14,21 +14,21 @@ namespace Sass { // simple endless recursion protection - const unsigned int maxRecursion = 500; - static unsigned int recursions = 0; + const size_t maxRecursion = 500; Expand::Expand(Context& ctx, Env* env, Backtrace* bt, std::vector* stack) : ctx(ctx), eval(Eval(*this)), + recursions(0), + in_keyframes(false), + at_root_without_rule(false), + old_at_root_without_rule(false), env_stack(std::vector()), block_stack(std::vector()), call_stack(std::vector()), selector_stack(std::vector()), media_block_stack(std::vector()), - backtrace_stack(std::vector()), - in_keyframes(false), - at_root_without_rule(false), - old_at_root_without_rule(false) + backtrace_stack(std::vector()) { env_stack.push_back(0); env_stack.push_back(env); @@ -685,12 +685,13 @@ namespace Sass { Statement_Ptr Expand::operator()(Mixin_Call_Ptr c) { - recursions ++; if (recursions > maxRecursion) { throw Exception::StackError(*c); } + recursions ++; + Env* env = environment(); std::string full_name(c->name() + "[m]"); if (!env->has(full_name)) { diff --git a/src/expand.hpp b/src/expand.hpp index e3245db862..1f93d2acbc 100644 --- a/src/expand.hpp +++ b/src/expand.hpp @@ -26,17 +26,18 @@ namespace Sass { Context& ctx; Eval eval; + size_t recursions; + bool in_keyframes; + bool at_root_without_rule; + bool old_at_root_without_rule; // it's easier to work with vectors - std::vector env_stack; + std::vector env_stack; std::vector block_stack; std::vector call_stack; std::vector selector_stack; std::vector media_block_stack; - std::vector backtrace_stack; - bool in_keyframes; - bool at_root_without_rule; - bool old_at_root_without_rule; + std::vector backtrace_stack; Statement_Ptr fallback_impl(AST_Node_Ptr n);