Fixed a nasty compiler bug where if the rhs of a ternary operator was larger than the lhs, the copy length emitted would only fit the lhs. The hier13() function now returns the larger of the lvalue sizes. (bug amb1853)
authorDavid Anderson <dvander@alliedmods.net>
Sun Sep 07 09:51:38 2008 +0000 (2008-09-07)
changeset 2273fc2bb71d0291
parent 2272 1f388ee7aa65
child 2274 80a5a7d4b259
Fixed a nasty compiler bug where if the rhs of a ternary operator was larger than the lhs, the copy length emitted would only fit the lhs. The hier13() function now returns the larger of the lvalue sizes. (bug amb1853)
sourcepawn/compiler/sc3.c
     1.1 --- a/sourcepawn/compiler/sc3.c	Sun Sep 07 03:56:45 2008 +0000
     1.2 +++ b/sourcepawn/compiler/sc3.c	Sun Sep 07 09:51:38 2008 +0000
     1.3 @@ -1346,6 +1346,15 @@
     1.4      if ((array1 && array2) && (total1 && total2)) {
     1.5        markheap(MEMUSE_DYNAMIC, 0);
     1.6      }
     1.7 +    /* If both sides are arrays, we should return the maximal as the lvalue.
     1.8 +     * Otherwise we could buffer overflow and the compiler is too stupid.
     1.9 +     * Literal strings have a constval == -(num_cells) so the cmp is flipped.
    1.10 +     */
    1.11 +    if (lval->ident==iARRAY && lval2.ident==iARRAY
    1.12 +        && lval->constval < 0
    1.13 +        && lval->constval > lval2.constval) {
    1.14 +      *lval = lval2;
    1.15 +    }
    1.16      if (lval->ident==iARRAY)
    1.17        lval->ident=iREFARRAY;    /* iARRAY becomes iREFARRAY */
    1.18      else if (lval->ident!=iREFARRAY)