Fix #9487: GIFLoad array subscript below array bounds

Recently enabled variable range propagation enables GCC to among others analyze
whether array subscript is in a valid range. While being quite useful this
particular feature also happens to produce false positives. This is merely
a workaround to make compiler happy.

The actual reason why compiler is reporting false positive is that array is
indexed with a signed integer and it is not clear for compiler what value it may
have due to it being a member of the class and and external procedure being
invoked between its initialization and usage.
This commit is contained in:
Pawel Dziepak 2013-02-28 23:08:16 +01:00
parent ea06a55228
commit 0b269c601f
2 changed files with 4 additions and 4 deletions

View File

@ -339,7 +339,7 @@ GIFLoad::ReadGIFImageData()
goto bad_end;
//memcpy(newEntry, fOldCode, fOldCodeLength);
for (int x = 0; x < fOldCodeLength; x++) {
for (unsigned int x = 0; x < fOldCodeLength; x++) {
newEntry[x] = fOldCode[x];
}
@ -347,7 +347,7 @@ GIFLoad::ReadGIFImageData()
newEntry[fOldCodeLength] = *fTable[fNewCode];
} else { // Does not exist in table
//memcpy(newEntry, fOldCode, fOldCodeLength);
for (int x = 0; x < fOldCodeLength; x++) {
for (unsigned int x = 0; x < fOldCodeLength; x++) {
newEntry[x] = fOldCode[x];
}
@ -360,7 +360,7 @@ GIFLoad::ReadGIFImageData()
fTable[fNextCode] = MemblockAllocate(fOldCodeLength + 1);
//memcpy(fTable[fNextCode], newEntry, fOldCodeLength + 1);
for (int x = 0; x < fOldCodeLength + 1; x++) {
for (unsigned int x = 0; x < fOldCodeLength + 1; x++) {
fTable[fNextCode][x] = newEntry[x];
}

View File

@ -86,7 +86,7 @@ class GIFLoad {
int fPass, fRow, fWidth, fHeight;
unsigned char fOldCode[4096];
int fOldCodeLength;
unsigned int fOldCodeLength;
short fNewCode;
int fBits, fMaxCode, fCodeSize;
short fClearCode, fEndCode, fNextCode;