Skip to content

Commit

Permalink
Malformed input support improved, fixes #394
Browse files Browse the repository at this point in the history
  • Loading branch information
koral-- committed Apr 17, 2017
1 parent 703d8a2 commit 018b12f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### 1.2.7-SNAPSHOT
- `GifDrawable` subclassing simplified - [#399](https://github.com/koral--/android-gif-drawable/pull/399)
- Malformed input support improved - [#394](https://github.com/koral--/android-gif-drawable/issues/394)
- Android Support library updated to 25.3.1
- Android gradle plugin updated to 2.3.1
- Gradle wrapper regenerated with 3.5
Expand Down
22 changes: 11 additions & 11 deletions android-gif-drawable/src/main/c/decoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {
uint_fast32_t lastAllocatedGCBIndex = 0;
do {
if (DGifGetRecordType(gifFilePtr, &RecordType) == GIF_ERROR) {
return;
break;
}
bool isInitialPass = !decode && !exitAfterFrame;
switch (RecordType) {
case IMAGE_DESC_RECORD_TYPE:

if (DGifGetImageDesc(gifFilePtr, isInitialPass) == GIF_ERROR) {
return;
break;
}

if (isInitialPass) {
Expand All @@ -51,7 +51,7 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {
sp->ImageDesc.Left -= leftOverflow;
}
if (!updateGCB(info, &lastAllocatedGCBIndex)) {
return;
break;
}
}

Expand All @@ -63,7 +63,7 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {
void *tmpRasterBits = reallocarray(info->rasterBits, newRasterSize, sizeof(GifPixelType));
if (tmpRasterBits == NULL) {
gifFilePtr->Error = D_GIF_ERR_NOT_ENOUGH_MEM;
return;
break;
}
info->rasterBits = tmpRasterBits;
info->rasterSize = newRasterSize;
Expand All @@ -80,11 +80,11 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {
for (i = 0; i < 4; i++)
for (j = InterlacedOffset[i]; j < gifFilePtr->Image.Height; j += InterlacedJumps[i]) {
if (DGifGetLine(gifFilePtr, info->rasterBits + j * gifFilePtr->Image.Width, gifFilePtr->Image.Width) == GIF_ERROR)
return;
break;
}
} else {
if (DGifGetLine(gifFilePtr, info->rasterBits, gifFilePtr->Image.Width * gifFilePtr->Image.Height) == GIF_ERROR) {
return;
break;
}
}

Expand All @@ -109,7 +109,7 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {
} else {
do {
if (DGifGetCodeNext(gifFilePtr, &ExtData) == GIF_ERROR) {
return;
break;
}
} while (ExtData != NULL);
if (exitAfterFrame) {
Expand All @@ -120,20 +120,20 @@ void DDGifSlurp(GifInfo *info, bool decode, bool exitAfterFrame) {

case EXTENSION_RECORD_TYPE:
if (DGifGetExtension(gifFilePtr, &ExtFunction, &ExtData) == GIF_ERROR) {
return;
break;
}
if (isInitialPass) {
updateGCB(info, &lastAllocatedGCBIndex);
if (readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return;
break;
}
}
while (ExtData != NULL) {
if (DGifGetExtensionNext(gifFilePtr, &ExtData) == GIF_ERROR) {
return;
break;
}
if (isInitialPass && readExtensions(ExtFunction, ExtData, info) == GIF_ERROR) {
return;
break;
}
}
break;
Expand Down

0 comments on commit 018b12f

Please sign in to comment.