Using CGraphic::Flip() on a 32-bit image causes a crash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Stratagus |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Something is amiss with this piece of code in CGraphic::Flip(), which is causing a crash when the function is used on a 32-bit image:
case 4: {
unsigned int p0 = s->pitch;
unsigned int p1 = Surface->pitch;
const int width = s->w;
int j = 0;
for (int i = 0; i < s->h; ++i) {
#ifdef _MSC_VER
for (j = 0; j < width; ++j) {
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
}
#else
int n = (width + 7) / 8;
switch (width & 7) {
case 0: do {
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 7:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 6:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 5:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 4:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 3:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 2:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
case 1:
*(Uint32 *)&((char *)s->pixels)[j * 4 + p0] =
*(Uint32 *) & ((char *)Surface-
j++;
} while (--n > 0);
}
#endif
p0 += s->pitch;
p1 += Surface->pitch;
}
}
break;
This project was moved to https:/ /github. com/Wargus/ stratagus. All issues were migrated there.