]> www.ginac.de Git - ginac.git/commit
mul: algebraic_subs_mul(), has(): don't write beyond the end of array
authorAlexei Sheplyakov <alexei.sheplyakov@gmail.com>
Sat, 9 Oct 2010 16:39:41 +0000 (18:39 +0200)
committerRichard Kreckel <kreckel@ginac.de>
Sat, 9 Oct 2010 16:40:59 +0000 (18:40 +0200)
commit052f124551d2b78104b0de2008db6b8819713625
treea9d552b8e67f375546449a287743b8795dd635a6
parentc40c54f17b68f79ee42833adb3364970385e2caa
mul: algebraic_subs_mul(), has(): don't write beyond the end of array

algebraic_match_mul_with_mul() iterates over operands of mul, that is

for (size_t i=0; i<e.nops(); ++i)

However, the size of arrays (`vectors' in STL speak) passed to this
function is seq.size(), which is nops() - 1 for any mul object. Thus
algebraic_match_mul_with_mul() accesses beyond the arrays limit. Usually
it's not a problem, since any reasonable implementation of std::vector<bool>
packs booleans into ints (or longs). However, some STL implementations
(in particular, the one shipped with msvc) are more picky, and access
beyond the vector<bool> limits results in a segfault. Therefore let's
play safe and allocate proper number of elements (that is, nops()) for
those arrays (subsed and currsubsed).
(cherry picked from commit cbb93fadabbd56ba006902967b15b2b2aebb037c)
ginac/mul.cpp