]> 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:39:41 +0000 (18:39 +0200)
commitcbb93fadabbd56ba006902967b15b2b2aebb037c
tree957b961481985fc9f70210373be386e21864daa4
parente99d0d58c1bbaa8ee73e4a90a90aa1086f2f813d
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).
ginac/mul.cpp