Bug 1160801 - Treat invalid GIF disposal methods as DisposalMethod::NOT_SPECIFIED. r=jrmuizel

This commit is contained in:
Seth Fowler 2015-05-14 15:19:39 -07:00
parent 0876f187ba
commit da93119c3d
5 changed files with 12 additions and 2 deletions

View File

@ -824,10 +824,15 @@ nsGIFDecoder2::WriteInternal(const char* aBuffer, uint32_t aCount)
mGIFStruct.is_transparent = *q & 0x1;
mGIFStruct.tpixel = q[3];
mGIFStruct.disposal_method = ((*q) >> 2) & 0x7;
// Some specs say 3rd bit (value 4), other specs say value 3
// Let's choose 3 (the more popular)
if (mGIFStruct.disposal_method == 4) {
// Some specs say 3rd bit (value 4), other specs say value 3.
// Let's choose 3 (the more popular).
mGIFStruct.disposal_method = 3;
} else if (mGIFStruct.disposal_method > 4) {
// This GIF is using a disposal method which is undefined in the spec.
// Treat it as DisposalMethod::NOT_SPECIFIED.
mGIFStruct.disposal_method = 0;
}
{

View File

@ -47,3 +47,8 @@ load multiple-png-hassize.ico
load 856616.gif
skip-if(AddressSanitizer) skip-if(B2G) load 944353.jpg
# Bug 1160801: Ensure that we handle invalid disposal types.
load invalid-disposal-method-1.gif
load invalid-disposal-method-2.gif
load invalid-disposal-method-3.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B