Jinja2Cpp icon indicating copy to clipboard operation
Jinja2Cpp copied to clipboard

Bug in 'reverse' filter

Open al-martyn1 opened this issue 3 years ago • 0 comments

    std::vector<std::string> foundTypes;
    jinja2::ValuesMap renderParams = 
    {   { "specTypes"    , jinja2::Reflect(&foundTypes)  }
    };
// ...

    if (...)
    {
        foundTypes = ...
        renderParams["specTypes"] = jinja2::Reflect(&foundTypes);
    }

Also, simple jinja makes the same effect:

{{ [3, 1, 2] | reverse }}

produces the bad_expected_access exception, which inspired by std::bad_alloc exception

// filters.cpp:452
InternalValue SequenceAccessor::Filter(const InternalValue& baseVal, RenderContext& context)
//...
// filters.cpp:479
listSize = {has_value_=true (0x34) contained={data={_Val=6.951334341138e-310#DEN _Pad=0x000000750f548880 "\x1ЉGyц" } } }
// 0x34 - 52 - size of my data vector
// requested size: size = 0x00007ff679478a01
// hex representation of 6.951334341138e-310 double is 0x00007ff679478a01

al-martyn1 avatar Apr 25 '22 22:04 al-martyn1