ncmul::eval(): don't write beyond the end of the vector.
authorAlexei Sheplyakov <varg@metalica.kh.ua>
Sat, 8 Aug 2009 10:03:38 +0000 (13:03 +0300)
committerRichard Kreckel <kreckel@ginac.de>
Thu, 30 Sep 2010 20:35:10 +0000 (22:35 +0200)
ginac/ncmul.cpp

index f21f857..adc36a5 100644 (file)
@@ -339,15 +339,15 @@ ex ncmul::eval(int level) const
        if (assocseq.empty()) return _ex1;
 
        // determine return types
-       unsignedvector rettypes;
-       rettypes.reserve(assocseq.size());
+       unsignedvector rettypes(assocseq.size());
        size_t i = 0;
        size_t count_commutative=0;
        size_t count_noncommutative=0;
        size_t count_noncommutative_composite=0;
        cit = assocseq.begin(); citend = assocseq.end();
        while (cit != citend) {
-               switch (rettypes[i] = cit->return_type()) {
+               rettypes[i] = cit->return_type();
+               switch (rettypes[i]) {
                case return_types::commutative:
                        count_commutative++;
                        break;