x86: fix pcmpestrm and pcmpistrm

Fix obvious typos (decrement and off-by-one error) in pcmpestrm and pcmpistrm
which resulted in infinite loop. Reported by Frank Mehnert,
spotted also by Coverity (bug 84752853).

Reported-by: Frank Mehnert <frank.mehnert@oracle.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Blue Swirl 2011-11-13 11:11:52 +00:00
parent 725e14e91f
commit bc4268998d
1 changed files with 8 additions and 4 deletions

View File

@ -1996,11 +1996,13 @@ void glue(helper_pcmpestrm, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
if ((ctrl >> 6) & 1) { if ((ctrl >> 6) & 1) {
if (ctrl & 1) if (ctrl & 1)
for (i = 0; i <= 8; i--, res >>= 1) for (i = 0; i < 8; i++, res >>= 1) {
d->W(i) = (res & 1) ? ~0 : 0; d->W(i) = (res & 1) ? ~0 : 0;
}
else else
for (i = 0; i <= 16; i--, res >>= 1) for (i = 0; i < 16; i++, res >>= 1) {
d->B(i) = (res & 1) ? ~0 : 0; d->B(i) = (res & 1) ? ~0 : 0;
}
} else { } else {
d->Q(1) = 0; d->Q(1) = 0;
d->Q(0) = res; d->Q(0) = res;
@ -2028,11 +2030,13 @@ void glue(helper_pcmpistrm, SUFFIX) (Reg *d, Reg *s, uint32_t ctrl)
if ((ctrl >> 6) & 1) { if ((ctrl >> 6) & 1) {
if (ctrl & 1) if (ctrl & 1)
for (i = 0; i <= 8; i--, res >>= 1) for (i = 0; i < 8; i++, res >>= 1) {
d->W(i) = (res & 1) ? ~0 : 0; d->W(i) = (res & 1) ? ~0 : 0;
}
else else
for (i = 0; i <= 16; i--, res >>= 1) for (i = 0; i < 16; i++, res >>= 1) {
d->B(i) = (res & 1) ? ~0 : 0; d->B(i) = (res & 1) ? ~0 : 0;
}
} else { } else {
d->Q(1) = 0; d->Q(1) = 0;
d->Q(0) = res; d->Q(0) = res;